Skip to content

feat: add CLI commands to manage AI Gateway keys - #25689

Merged
pawbana merged 3 commits into
mainfrom
pb/gateway-multi-replica-key-auth-cli
Jun 18, 2026
Merged

pawbana merged 3 commits into
mainfrom
pb/gateway-multi-replica-key-auth-cli

Conversation

@pawbana

@pawbana pawbana commented May 26, 2026 •

Copy link
Copy Markdown
Collaborator

Adds coder ai-gateway keys commands:

  • create <name> creates key with given name
  • list lists existing keys (alias ls)
  • delete <name | id> removes key matching by name or key id, name has priority (alias rm)

@pawbana
pawbana requested a review from Emyrk as a code owner May 26, 2026 17:07
@pawbana
pawbana changed the base branch from main to graphite-base/25689 May 26, 2026 17:07
@pawbana
pawbana force-pushed the graphite-base/25689 branch from d80b484 to a3c0764 Compare May 26, 2026 17:07
@pawbana
pawbana changed the base branch from graphite-base/25689 to pb/gateway-multi-replica-key-auth-endpoints May 26, 2026 17:07

pawbana commented May 26, 2026 •

Copy link
Copy Markdown
Collaborator Author

@Emyrk

Emyrk commented May 27, 2026

Copy link
Copy Markdown
Member

@pawbana if this is a WIP can you make it a draft PR?

@pawbana
pawbana marked this pull request as draft May 27, 2026 16:30
@pawbana
pawbana force-pushed the pb/gateway-multi-replica-key-auth-cli branch from ba4650a to 1eea0de Compare May 28, 2026 07:23
@pawbana
pawbana force-pushed the pb/gateway-multi-replica-key-auth-endpoints branch from a3c0764 to dea0ea0 Compare May 28, 2026 10:18
@pawbana
pawbana force-pushed the pb/gateway-multi-replica-key-auth-cli branch from 1eea0de to 226a1b6 Compare May 28, 2026 10:18
@pawbana
pawbana force-pushed the pb/gateway-multi-replica-key-auth-endpoints branch from dea0ea0 to ab30aa1 Compare May 28, 2026 12:03
@pawbana
pawbana force-pushed the pb/gateway-multi-replica-key-auth-cli branch from 226a1b6 to 3140926 Compare May 28, 2026 12:03
@pawbana
pawbana force-pushed the pb/gateway-multi-replica-key-auth-endpoints branch from ab30aa1 to fd90423 Compare May 28, 2026 20:20
@pawbana
pawbana force-pushed the pb/gateway-multi-replica-key-auth-cli branch from 3140926 to e929815 Compare May 28, 2026 20:20
@github-actions

github-actions Bot commented May 28, 2026 •

Copy link
Copy Markdown
Contributor

Docs preview

📖 View docs preview for docs/reference/cli/ai-gateway.md

@pawbana
pawbana force-pushed the pb/gateway-multi-replica-key-auth-endpoints branch from fd90423 to e6f1f5e Compare May 29, 2026 10:48
@pawbana
pawbana force-pushed the pb/gateway-multi-replica-key-auth-cli branch from e929815 to 2da5a54 Compare May 29, 2026 10:48
@pawbana
pawbana force-pushed the pb/gateway-multi-replica-key-auth-endpoints branch from e6f1f5e to f6f84b1 Compare May 29, 2026 15:24
@pawbana
pawbana force-pushed the pb/gateway-multi-replica-key-auth-cli branch 2 times, most recently from c4c363c to e953487 Compare June 1, 2026 11:33
@pawbana
pawbana force-pushed the pb/gateway-multi-replica-key-auth-endpoints branch 2 times, most recently from 9b40bf8 to 432c1ea Compare June 1, 2026 14:47
@pawbana
pawbana force-pushed the pb/gateway-multi-replica-key-auth-cli branch from e953487 to ac72698 Compare June 1, 2026 14:47
@pawbana
pawbana force-pushed the pb/gateway-multi-replica-key-auth-endpoints branch from 432c1ea to bf3f6a7 Compare June 1, 2026 18:47
@pawbana
pawbana force-pushed the pb/gateway-multi-replica-key-auth-cli branch from 6188504 to 1ed0e5c Compare June 2, 2026 14:20
@pawbana
pawbana force-pushed the pb/gateway-multi-replica-key-auth-endpoints branch from d365992 to 2f6ac7f Compare June 2, 2026 14:36
@pawbana
pawbana force-pushed the pb/gateway-multi-replica-key-auth-cli branch 3 times, most recently from e58391e to f039577 Compare June 3, 2026 11:32
Base automatically changed from pb/gateway-multi-replica-key-auth-endpoints to main June 3, 2026 11:50
@pawbana
pawbana force-pushed the pb/gateway-multi-replica-key-auth-cli branch 3 times, most recently from 188d365 to f694bee Compare June 3, 2026 15:16
@pawbana
pawbana marked this pull request as ready for review June 3, 2026 15:17
@pawbana

pawbana commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

@coder-agents-review

coder-agents-review Bot commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

Chat: Review posted | View chat
Requested: 2026-06-17 15:20 UTC by @pawbana
Spend: $48.31 / $100.00

Review history
  • R2 (2026-06-17): 6 reviewers, 4 Nit, 5 P3, COMMENT. Review

deep-review v0.7.1 | Round 2 | 9f2d88f..3d29d0d

Last posted: Round 2, 9 findings (5 P3, 4 Nit), COMMENT. Review

Finding inventory

Findings

# Sev Status Location Summary Round Reviewer Posted
CRF-1 P2 Author fixed (3d29d0d) enterprise/cli/aigateway.go:119 Delete only accepts UUID; PR description promises delete <name | id> R1 Mafu-san P2, Pariston P2, Ryosuke P2, Luffy P2, Mafuuu P3, Leorio P3, Chopper P3, Kite P3, Zoro P3, Knov P3 Yes
CRF-2 P3 Author fixed (3d29d0d) enterprise/cli/root.go:21 ai and aibridge coexist as separate top-level commands for the same product area R1 Gon P3, Ryosuke P3, Zoro P3, Luffy P3, Knov Note, Robin Note Yes
CRF-3 P3 Author fixed (3d29d0d) enterprise/cli/aigateway.go:139 Delete confirmation prompt shows only UUID, not key name R1 Leorio P3, Chopper P3, Mafuuu Note, Kite Nit Yes
CRF-4 P3 Author fixed (3d29d0d) enterprise/cli/aigateway_test.go:173 MemberForbidden test loop without t.Run hides which operation fails R1 Bisky P3, Hisoka Nit Yes
CRF-5 P3 Author fixed (3d29d0d) enterprise/cli/aigateway_test.go:69 Create output test doesn't verify secret key appears in stdout R1 Bisky P3 Yes
CRF-6 P3 Author fixed (3d29d0d) enterprise/cli/aigateway_test.go:82 Table output never tested with data rows; only tested when empty R1 Hisoka P3 Yes
CRF-7 Nit Author fixed (3d29d0d) enterprise/cli/aigateway.go:84 Missing ls alias on list subcommand R1 Ryosuke Nit, Knov Nit Yes
CRF-8 Nit Author fixed (3d29d0d) enterprise/cli/aigateway.go:46 Inconsistent trailing periods on Short descriptions (parents have periods, leaves don't) R1 Leorio Nit Yes
CRF-9 Nit Dropped by orchestrator (generated artifact from test framework) enterprise/cli/testdata/coder_ai_gateway_keys_--help_--help.golden Duplicate golden file identical to --help variant R1 Zoro Nit No
CRF-10 Nit Dropped by orchestrator (accurate section markers with navigational value) enterprise/cli/aigateway_test.go:53 Test comments restate code (5 instances) R1 Gon P2 No
CRF-11 Note Dropped by orchestrator (product namespace decision) enterprise/cli/ai.go:7 Four levels of nesting for CRUD with single-child intermediates R1 Zoro P3, Luffy Note No

| CRF-12 | Nit | Open | enterprise/cli/aigateway.go:18 | Parent Short descriptions have trailing periods against codebase majority convention | R2 | Pariston Nit, Leorio Nit | Yes |
| CRF-13 | Nit | Open | enterprise/cli/aigateway.go:164 | Parameter arg should be nameOrID | R2 | Gon Nit | Yes |
| CRF-14 | Nit | Dropped by orchestrator (accurate test helper docs, minimal consequence) | enterprise/cli/aigateway_test.go:42 | Test helper doc comments restate return signatures (5 instances) | R2 | Gon P2 | No |
| CRF-15 | Nit | Dropped by orchestrator (clear from test name and assertion) | enterprise/cli/aigateway_test.go:190 | Magic number 65 from undocumented 64-char limit | R2 | Gon P3 | No |
| CRF-16 | Nit | Dropped by orchestrator (lint suppression, not documentation) | enterprise/cli/aigateway_test.go:46 | nolint:gocritic comment misrepresents helper function usage | R2 | Chopper Nit | No |

Round log

Round 1

Panel (15 reviewers + Netero). Netero clean. 1 P2, 5 P3, 2 Nit posted. 2 Nit dropped, 1 Note dropped. Reviewed against b9c3eea..f694bee.

Round 2

Panel (6 reviewers + Netero). CRF-1 through CRF-8 verified fixed. 2 Nit posted, 3 Nit dropped. Reviewed against 9f2d88f..3d29d0d.

About deep-review

CRF = Coder Review Finding (P0-P4, Nit, Note)

Reviewer Focus
Bisky tests
Chopper ops/errors
Churn-guard change verification
Ging language modernization
Gon naming
Hisoka edge cases
Killua perf
Kite change integrity
Knov contracts
Knuckle SQL
Kurapika security
Law decomposition
Leorio docs
Luffy product
Mafu-san process
Mafuuu contracts
Melody dispatch/pairing
Meruem structural
Nami frontend
Netero mechanical checks
Pariston premise testing
Pen-botter product gaps
Razor verification
Robin duplication
Ryosuke Go arch
Takumi concurrency
Zoro shape

🤖 Managed by Coder Agents.

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean CLI surface for AI Gateway key management. Good test density (56.5%), proper use of shared CLI primitives, and the enterprise command list alphabetization is a nice touch.

Severity count: 1 P2, 5 P3, 2 Nit.

The dominant finding (10 of 15 reviewers flagged it): the PR description promises delete <name | id> but the code only accepts UUID. The code is internally consistent; the description is the outlier. This needs either a description fix or a name-lookup implementation.

Secondary theme: the ai / aibridge namespace split. Both gate on FeatureAIBridge, both manage the same product area, and both appear side by side in coder --help with no cross-reference. This is a product decision, but it's now user-visible.

"A user who creates a key with coder ai gateway keys create my-key and then tries coder ai gateway keys delete my-key will get: parse AI Gateway key ID "my-key": invalid UUID length: 6. That error message doesn't explain what they should do instead." (Pariston)

🤖 This review was automatically generated with Coder Agents.

Comment thread enterprise/cli/aigateway.go Resolved
Comment thread enterprise/cli/root.go Resolved
Comment thread enterprise/cli/aigateway.go Resolved
Comment thread enterprise/cli/aigateway_test.go Resolved
Comment thread enterprise/cli/aigateway_test.go Resolved
Comment thread enterprise/cli/aigateway_test.go Resolved
Comment thread enterprise/cli/aigateway.go Resolved
Comment thread enterprise/cli/aigateway.go Resolved
@pawbana
pawbana force-pushed the pb/gateway-multi-replica-key-auth-cli branch from f694bee to 3820e9b Compare June 17, 2026 11:07
@linear-code

linear-code Bot commented Jun 17, 2026

Copy link
Copy Markdown

AIGOV-312

@pawbana
pawbana force-pushed the pb/gateway-multi-replica-key-auth-cli branch from 3820e9b to 492e149 Compare June 17, 2026 15:13
@pawbana
pawbana force-pushed the pb/gateway-multi-replica-key-auth-cli branch from 492e149 to 3d29d0d Compare June 17, 2026 15:14
@pawbana

pawbana commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All 8 findings from round 1 verified fixed in the current code. The aiGatewayKeyByNameOrID resolution is well-structured, with name-first priority and a collision test that creates a key whose name is another key's UUID. The test restructuring (extracted helpers, table-driven MemberForbidden, table output assertions, secret key validation) significantly improved test quality.

Severity count: 0 P2, 0 P3, 2 Nit new. CRF-1 through CRF-8 all confirmed resolved.

"The collision test is the real gem: it creates a key whose name is another key's ID, then proves delete resolves by name first. That's not a box-checking test; that's someone thinking about what would actually break." (Bisky)

🤖 This review was automatically generated with Coder Agents.

Comment thread enterprise/cli/aigateway.go Resolved
Comment thread enterprise/cli/aigateway.go Resolved
@pawbana
pawbana force-pushed the pb/gateway-multi-replica-key-auth-cli branch from c1264a0 to 6419b65 Compare June 17, 2026 16:08

@dannykopping dannykopping left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, couple non-blocking nits based on my own taste.

Comment thread enterprise/cli/aigateway_test.go Outdated
require.Contains(t, stdout, "Successfully created AI Gateway key "+name)

// The one-time secret key must be rendered as KeyLength alphanumerics.
require.Contains(t, stdout, "Save this authentication token")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I don't see much value in testing for this TBH.

require.Contains(t, stdout, "Save this authentication token")
require.Len(t, aiGatewayKeyRe.FindStringSubmatch(stdout), 2, "expected secret key in create output")

matches := aiGatewayCreateRe.FindStringSubmatch(stdout)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this is flimsy. I'd prefer that we mocked the key creation so we know exactly what is being returned, and then ensure the output contains that key.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By using real endpoints this test is more E2E like. With mocks it could only check CLI rendering which I think would be a bit lacking.

@pawbana
pawbana enabled auto-merge (squash) June 18, 2026 08:54
@pawbana
pawbana merged commit 0dbe044 into main Jun 18, 2026
33 of 34 checks passed
@pawbana
pawbana deleted the pb/gateway-multi-replica-key-auth-cli branch June 18, 2026 09:08
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants