Repository navigation
Vanguard: Accept the API address without /api/v2 - #5
Merged
Merged
Conversation
NEXRENDER_API_URL, --server and profile servers had to spell out the /api/v2 base. Given only the API's address (https://api.nexrender.com, as people naturally write it), every request went to /jobs, /templates and so on at the root and failed with "Not Found", which auth status reported as a rejected credential. A server that is just the address, or ends in /api, now gets /api/v2. Any other path is kept, so gateways that mount the API elsewhere still work, and URLs that already end in /api/v2 are unchanged. Found by Vanguard.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The CLI only worked when
NEXRENDER_API_URL,--serveror a profile's server spelled out the/api/v2base. People naturally give the API's address (https://api.nexrender.com). The generated client then sent every request to/jobs,/templatesand so on at the root and got404 Not Found.nexrender auth statusreported that 404 as a credential that was not accepted, which sends people looking at their token instead of the URL.config.NormalizeServer, which every server source already goes through, now adds the base:https://api.nexrender.comhttps://api.nexrender.com/api/v2https://staging.api.nexrender.com/…/api/v2https://staging.api.nexrender.com/api…/api/v2https://staging.api.nexrender.com/api/v2https://gateway.example.test/nexrender/v2The v3 client still derives its root by dropping
/v2, so template commands keep working. The invalid-URL hint now asks for the API address instead of a full/api/v2URL.This repository only has
main, so the PR targets it.Found by Vanguard, the new end-to-end suite: its staging run failed preflight with the API address alone.
Testing
TestNormalizeServerDerivesTheAPIBasecovers a bare host, a trailing slash,/api, an explicit/api/v2, a local port, a custom gateway path, empty input and a non-URL.gofmt -l(clean),go vet ./...,go test ./....NEXRENDER_API_URL=https://staging.api.nexrender.com:auth statusresolves the server to…/api/v2and authenticates, andtemplate list(v3) returns the team's templates.