Skip to content

pick the url of the traffic target we asked for - #599

Open
rootkiller6788 wants to merge 3 commits into
google-github-actions:mainfrom
rootkiller6788:fix-update-traffic-output-url
Open

rootkiller6788 wants to merge 3 commits into
google-github-actions:mainfrom
rootkiller6788:fix-update-traffic-output-url

Conversation

@rootkiller6788

Copy link
Copy Markdown

Fixes #589.

The url output of the action came from whichever traffic target gcloud happened to print first with a url, but gcloud prints every target of the service, not just the one we changed. So deploying with revision_traffic: 'LATEST=100' on a service that also has an older revision tagged at 0% traffic could hand you back that older revision's tag url - a url that has nothing to do with the deploy that just ran.

parseUpdateTrafficResponse now takes the revision_traffic/tag_traffic string we passed to gcloud and matches the entry it refers to. For a revision target it returns the service url; for a tag target it returns that tag's url. When nothing matches (for example if the target was set through update_traffic_flags) it keeps the old behavior, so existing callers are unaffected.

Two things worth calling out:

  • for a revision target I return the service url rather than a tag url. The url output is documented as "the URL of the Cloud Run service", and a revision can carry tags unrelated to this deploy. An explicitly requested tag is the case where a tag url is what you want.
  • the tags field in the gcloud response is a list of {tag, url, inSpec, inStatus} objects, not strings. The declared type was wrong (our own fixtures already used the object form), so I fixed the type while I was in there.

Tests: 4 new cases in tests/unit/output-parser.test.ts (the LATEST=100 case from the issue, selecting a specific tag, and the two fallbacks). All 54 unit tests pass, eslint and the ncc build are clean. Reverting the parser change makes exactly the 4 new cases fail, so they do cover the bug.

gcloud returns tags as objects ({tag, url, inSpec, inStatus}), not strings.
Our own test fixtures already use the object form, so the declared type was
just wrong. Making the other fields optional too, since gcloud omits some of
them depending on the version.
The parser walked the output and grabbed the first url it found, but gcloud
prints every traffic target of the service, not just the one we changed. So
with `--to-revisions LATEST=100` on a service that also has an old tagged
revision at 0% traffic, the output url could be the tag url of that unrelated
revision.

Now we pass revision_traffic/tag_traffic into the parser and match on the
target that was requested. For a revision we return the service url, for a tag
we return that tag's url. If the target isn't in the output we keep the old
behavior.
Covers the LATEST=100 case from google-github-actions#589 (a tagged revision at 0% traffic listed
first), picking a specific tag, and the fallbacks.
@rootkiller6788
rootkiller6788 marked this pull request as ready for review December 3, 2026 04:13
@rootkiller6788
rootkiller6788 requested a review from a team as a code owner December 3, 2026 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

output url returns unrelated tag revision url

1 participant