feat(run-commit): accept repo:tag refs via --ref flag#186
Draft
feat(run-commit): accept repo:tag refs via --ref flag#186
Conversation
Before this change, 'vers run-commit <arg>' always sent the argument as
{"commit_id": ...} in the API request. Passing a repo:tag reference
like 'my-app:latest' failed with 422 Unprocessable Entity because the
server tried to parse it as a UUID.
--ref switches the underlying payload to {"ref": ...}, which the API
resolves against tags in the caller's own org. The positive case was
verified end-to-end against pi-agent:latest.
Also added a friendly error when the argument looks like a repo:tag
(contains ':') and --ref was omitted, pointing the user at the right
flag instead of hitting a generic 422 from the API.
Two new files, matching the existing repo test style (tags_test.go
pattern for handler tests via httptest.NewServer, routing_test.go
table-driven pattern for cmd-level pure-function tests):
internal/handlers/run_commit_test.go:
- TestHandleRunCommit_CommitIDPath — verifies default (IsRef=false)
sends commit_id, no ref key in body
- TestHandleRunCommit_RefPath — verifies IsRef=true sends ref,
no commit_id key
- TestHandleRunCommit_ServerError — verifies non-2xx surfaces as
a caller-visible error (no silent swallowing)
cmd/run_commit_test.go:
- TestLooksLikeRepoRef (table-driven, 16 cases) — positive: canonical
repo:tag shapes with various legal chars. Negative: empty/no-colon,
malformed colon placement, chars outside the legal name set (space,
slash, @, #, non-ASCII).
- TestLooksLikeRepoRef_MultipleColons — documents the current (intended)
behavior for a:b:c as NOT matching, since the second colon isn't a
legal name char.
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
vers run-commit <arg>previously always sent{commit_id: ...}to the API, which meant any non-UUID argument (e.g. a repo:tag reference likemy-app:latest) hit a generic 422 from the server.This change adds a
--refflag that switches the request payload to{ref: ...}, letting the API resolve repo tags in the caller's own org.Also adds a friendly error when the argument looks like a repo:tag (contains
:) and--refwas omitted, pointing users at the right flag instead of a cryptic 422.Verification
The positive case was verified end-to-end against
pi-agent:latestin prod.Followups (not in this PR)
looksLikeRepoRef+ handler-level tests mirroringinternal/handlers/tags_test.go(mockhttptest.NewServer, assert the request body contains"ref"vs"commit_id"). Say the word.