Skip to content

feat(run-commit): accept repo:tag refs via --ref flag#186

Draft
nsluss wants to merge 2 commits intomainfrom
feat/run-commit-ref-flag
Draft

feat(run-commit): accept repo:tag refs via --ref flag#186
nsluss wants to merge 2 commits intomainfrom
feat/run-commit-ref-flag

Conversation

@nsluss
Copy link
Copy Markdown

@nsluss nsluss commented Apr 20, 2026

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 like my-app:latest) hit a generic 422 from the server.

This change adds a --ref flag 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 --ref was omitted, pointing users at the right flag instead of a cryptic 422.

Verification

The positive case was verified end-to-end against pi-agent:latest in prod.

Followups (not in this PR)

  • No unit tests yet. Happy to add table-driven tests for looksLikeRepoRef + handler-level tests mirroring internal/handlers/tags_test.go (mock httptest.NewServer, assert the request body contains "ref" vs "commit_id"). Say the word.

noah and others added 2 commits April 20, 2026 17:53
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant