Skip to content

feat: add DB queries for ai_gateway_coderd_keys#25564

Merged
pawbana merged 6 commits into
mainfrom
pb/gateway-multi-replica-key-auth-db-queries
Jun 2, 2026
Merged

feat: add DB queries for ai_gateway_coderd_keys#25564
pawbana merged 6 commits into
mainfrom
pb/gateway-multi-replica-key-auth-db-queries

Conversation

@pawbana
Copy link
Copy Markdown
Contributor

@pawbana pawbana commented May 21, 2026

Adds Insert, List and Delete queries for ai_gateway_coderd_keys table.

Copy link
Copy Markdown
Contributor Author

pawbana commented May 21, 2026

@pawbana pawbana changed the title feat: add DB queries and RBAC for aibridge_coderd_keys feat: add DB queries for aibridge_coderd_keys May 21, 2026
@pawbana pawbana force-pushed the pb/gateway-multi-replica-key-auth-db-queries branch from 884d73a to 07965bc Compare May 21, 2026 12:26
@pawbana pawbana force-pushed the pb/gateway-multi-replica-key-auth-db-queries branch from 07965bc to 4809647 Compare May 21, 2026 13:14
@pawbana pawbana force-pushed the pb/gateway-multi-replica-key-auth-db branch from f842713 to 3248cc3 Compare May 21, 2026 13:14
@pawbana pawbana force-pushed the pb/gateway-multi-replica-key-auth-db-queries branch from 4809647 to 68caa22 Compare May 21, 2026 13:30
@pawbana pawbana force-pushed the pb/gateway-multi-replica-key-auth-db branch 2 times, most recently from 056ea4d to ea066e6 Compare May 21, 2026 14:35
@pawbana pawbana force-pushed the pb/gateway-multi-replica-key-auth-db-queries branch 2 times, most recently from 09af228 to 9851434 Compare May 21, 2026 15:57
@pawbana pawbana force-pushed the pb/gateway-multi-replica-key-auth-db branch 2 times, most recently from 3c2624b to ca08383 Compare May 21, 2026 16:47
@pawbana pawbana force-pushed the pb/gateway-multi-replica-key-auth-db-queries branch 4 times, most recently from 56911cf to 4a8ae2b Compare May 21, 2026 17:54
@pawbana
Copy link
Copy Markdown
Contributor Author

pawbana commented May 21, 2026

/coder-agents-review

Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

Solid query-layer PR. The three queries are well-structured: explicit column subsets that exclude hashed_secret from return types (structural security boundary enforced at the SQL level, not caller discipline), correct RBAC resource/action pairing, and thorough constraint tests covering all six DB constraints. Pariston tried to build a case against the design and couldn't. Kite praised the secret-exclusion pattern specifically. Mafuuu traced the full contract chain and confirmed correctness.

3 P3, 2 Nit. No blockers.

Process note: the PR title says aibridge_coderd_keys but the actual table is ai_gateway_coderd_keys. When this squash-merges, git log --grep ai_gateway_coderd_keys won't find it. Worth fixing the title before merge.

"I tried to build a case against this change and couldn't. The problem is correctly understood, the solution is proportional, and the fix is at the right level of the stack." (Pariston)

🤖 This review was automatically generated with Coder Agents.

Comment thread coderd/database/queries/ai_gateway_coderd_keys.sql Outdated
Comment thread coderd/database/querier_test.go
Comment thread coderd/database/querier_test.go Outdated
Comment thread coderd/database/querier_test.go
Comment thread coderd/database/querier_test.go Outdated
@pawbana pawbana changed the title feat: add DB queries for aibridge_coderd_keys feat: add DB queries for ai_gateway_coderd_keys May 22, 2026
@pawbana pawbana marked this pull request as ready for review May 22, 2026 08:54
@pawbana pawbana force-pushed the pb/gateway-multi-replica-key-auth-db-queries branch from 4c654bf to f397e3c Compare May 22, 2026 09:34
@pawbana pawbana force-pushed the pb/gateway-multi-replica-key-auth-db branch from 2a07176 to d2a7b79 Compare May 22, 2026 09:34
@pawbana pawbana force-pushed the pb/gateway-multi-replica-key-auth-db-queries branch from f397e3c to b932b20 Compare May 22, 2026 13:48
@pawbana pawbana force-pushed the pb/gateway-multi-replica-key-auth-db branch from 1adb398 to f9c6e92 Compare May 22, 2026 15:13
@pawbana pawbana force-pushed the pb/gateway-multi-replica-key-auth-db-queries branch from b932b20 to 535c9cd Compare May 22, 2026 15:13
@pawbana pawbana force-pushed the pb/gateway-multi-replica-key-auth-db-queries branch from 3fedbd0 to 267827f Compare May 28, 2026 20:20
@pawbana pawbana force-pushed the pb/gateway-multi-replica-key-auth-db branch from 8239275 to ab58a2f Compare May 29, 2026 10:48
@pawbana pawbana force-pushed the pb/gateway-multi-replica-key-auth-db-queries branch 2 times, most recently from 6405f23 to dad326f Compare May 29, 2026 15:24
@pawbana pawbana force-pushed the pb/gateway-multi-replica-key-auth-db branch 2 times, most recently from 335b73d to 13dd6ae Compare June 1, 2026 11:33
@pawbana pawbana force-pushed the pb/gateway-multi-replica-key-auth-db-queries branch 2 times, most recently from 74ac18e to 6ce1b97 Compare June 1, 2026 14:47
@pawbana pawbana force-pushed the pb/gateway-multi-replica-key-auth-db branch 2 times, most recently from 1bfe3cc to 37daa9f Compare June 1, 2026 18:47
@pawbana pawbana force-pushed the pb/gateway-multi-replica-key-auth-db-queries branch 2 times, most recently from 328502b to d5c8d95 Compare June 1, 2026 18:48
@pawbana pawbana force-pushed the pb/gateway-multi-replica-key-auth-db branch 2 times, most recently from 318ebc9 to 06ad9f0 Compare June 2, 2026 07:06
@pawbana pawbana force-pushed the pb/gateway-multi-replica-key-auth-db-queries branch from d5c8d95 to 1873fdc Compare June 2, 2026 07:06
Base automatically changed from pb/gateway-multi-replica-key-auth-db to main June 2, 2026 07:28
@pawbana pawbana requested a review from Emyrk as a code owner June 2, 2026 07:28
@pawbana pawbana force-pushed the pb/gateway-multi-replica-key-auth-db-queries branch 2 times, most recently from 0fa846e to 889b7a6 Compare June 2, 2026 09:39
pawbana added 5 commits June 2, 2026 10:24
Adds Insert / List / Delete queries on aibridge_coderd_keys plus the
ResourceAIGatewayCoderdKey RBAC object (Create / Read / Delete actions).
The hashed_secret column is intentionally excluded from every query's
RETURNING / SELECT list, so generated row types never carry it.

Also extends the migration with token_prefix (varchar(11)), the
'aibridge_coderd_key' resource_type enum value for audit support, and
ai_gateway_coderd_key:{*,create,delete,read} api_key_scope values.
@pawbana pawbana force-pushed the pb/gateway-multi-replica-key-auth-db-queries branch from 889b7a6 to 324ac9d Compare June 2, 2026 10:52
@pawbana pawbana merged commit 32aee9e into main Jun 2, 2026
25 checks passed
@pawbana pawbana deleted the pb/gateway-multi-replica-key-auth-db-queries branch June 2, 2026 11:25
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 2, 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.

2 participants