Repository navigation
feat: add AI provider chat routes - #25413
ibetitsmike wants to merge 1 commit into
Conversation
|
/coder-agents-review |
There was a problem hiding this comment.
First-pass review (Netero). These are mechanical findings from the first pass only; the full review panel has not yet reviewed this PR. The panel will review after these findings are addressed.
Severity count: 1 P1, 1 P2, 2 P3.
The CRUD surface is well-structured and consistent with the existing chat provider pattern. Route registration, authorization checks, and converter functions are clean. The naming follows established conventions throughout.
"675+ new lines of non-test Go code with 0 new handler tests. The only test changes are 3 lines adding Name: to existing dbcrypt tests." (Netero)
🤖 This review was automatically generated with Coder Agents.
|
/coder-agents-review |
3 similar comments
|
/coder-agents-review |
|
/coder-agents-review |
|
/coder-agents-review |
There was a problem hiding this comment.
Panel review (R2, 10 reviewers). All four R1 Netero findings addressed cleanly in e82b66fb9.
The CRUD surface is well-organized: consistent naming, correct RBAC checks, clean converters. The new test suite covers the main lifecycle and key validation paths.
Severity count: 7 P2, 4 P3, 2 Nit.
The findings cluster around three themes: (1) missing input validation that the legacy chat provider handlers already implement (key size cap, BaseURL normalization, whitespace trimming), (2) mutation handlers that lack transactions and row locks (updateAIProvider and deleteAIProvider), and (3) test gaps on error branches that guard the R1 fixes.
Ryosuke's structural observation: wrapping updateAIProvider and deleteAIProvider in InTx with GetForUpdate (the pattern deleteChatProvider already uses) resolves DEREM-7 and DEREM-8 simultaneously, and makes parent-existence checks structurally natural.
"675+ new lines of non-test Go code with 0 new handler tests" was the R1 finding. The author shipped 223 lines of tests covering all 11 handlers. Solid turnaround. (Netero R1 vs R2)
coderd/database/migrations/000498_ai_providers_schema_expand.up.sql:33
Nit [DEREM-18] idx_user_ai_provider_keys_user_id is redundant.
The UNIQUE (user_id, ai_provider_id) constraint implicitly creates a composite index with user_id as the leading column. PostgreSQL can use a composite index for prefix lookups, so queries filtering only on user_id (e.g., GetUserAIProviderKeysByUserID) are already served by the unique index. The standalone index adds write amplification with no query benefit. Consider dropping it and keeping only idx_user_ai_provider_keys_ai_provider_id for the non-leading column.
(Knuckle Nit)
🤖
🤖 This review was automatically generated with Coder Agents.
There was a problem hiding this comment.
Review blocked (R3). All 13 open findings from the panel review (R2) are unaddressed. No code changes to the affected files since R2. Further review is blocked until the author responds or pushes fixes.
Unaddressed P2 findings (7):
- DEREM-5:
upsertUserAIProviderKeyallows key attachment to disabled providers - DEREM-6: No API key size validation in
createAIProviderKey/upsertUserAIProviderKey - DEREM-7:
deleteAIProviderreturns 204 for non-existent or already-deleted providers - DEREM-8:
updateAIProviderread-then-update without transaction; lost updates and 500 on concurrent soft-delete - DEREM-9: BaseURL stored without validation; SSRF vector when consumed by bridge
- DEREM-10: All 11 handlers discard DB errors in 500 responses (no Detail, no logging)
- DEREM-11:
updateAIProvidervalidation error paths untested
Unaddressed P3 findings (4):
- DEREM-12:
listAIProviderKeysreturns 200 for non-existent provider IDs - DEREM-13: Cross-provider key deletion check untested
- DEREM-14:
listUserAIProviderKeyConfigsfiltering logic untested - DEREM-15:
BYOKDisabledRejectsUpsertAndAllowsDeletetests delete of non-existent key
Unaddressed Nit findings (2):
- DEREM-16: API key whitespace not trimmed before storage
- DEREM-18: Redundant index
idx_user_ai_provider_keys_user_id
🤖 This review was automatically generated with Coder Agents.
|
/coder-agents-review |
1 similar comment
|
/coder-agents-review |
There was a problem hiding this comment.
Review blocked (R4). 6 of 13 findings addressed in a73506515 (DEREM-5, 6, 7, 8, 9, 16). Good progress on the P2 input validation and transaction fixes. 7 findings remain unaddressed with no author response.
Still silent P2 findings (2):
- DEREM-10: All 11 handlers discard DB errors in 500 responses (no
Detail, no logging) - DEREM-11:
updateAIProvidervalidation error paths untested (409 on duplicate name, 400 on invalid name via update)
Still silent P3 findings (4):
- DEREM-12:
listAIProviderKeysreturns 200 for non-existent provider IDs - DEREM-13: Cross-provider key deletion check untested
- DEREM-14:
listUserAIProviderKeyConfigsfiltering logic untested - DEREM-15:
BYOKDisabledRejectsUpsertAndAllowsDeletetests delete of non-existent key
Still silent Nit (1):
- DEREM-18: Redundant index
idx_user_ai_provider_keys_user_id
Further review is blocked until the author responds or pushes fixes for the remaining findings. Even a brief "intentional, will not fix" acknowledgment unblocks the review.
🤖 This review was automatically generated with Coder Agents.
There was a problem hiding this comment.
Review blocked (R5). Same 7 findings from R4 remain silent. Only docs changes since last round.
Silent P2 (2): DEREM-10 (500 responses discard errors), DEREM-11 (update validation untested).
Silent P3 (4): DEREM-12, 13, 14, 15.
Silent Nit (1): DEREM-18.
This is the third consecutive blocked round (R3, R4, R5). The review cannot proceed without author engagement on these findings. A brief reply (even "will not fix" or "deferred") unblocks the next round.
🤖 This review was automatically generated with Coder Agents.
|
/coder-agents-review |
There was a problem hiding this comment.
Review blocked (R6). Fourth consecutive blocked round. Same 7 findings remain silent since R2. No handler or test changes since R4.
Silent P2 (2): DEREM-10 (500 responses discard errors), DEREM-11 (update validation untested).
Silent P3 (4): DEREM-12, 13, 14, 15.
Silent Nit (1): DEREM-18.
The review process has stalled. These findings need a human decision: fix, acknowledge, or defer with a ticket. Repeated /coder-agents-review triggers without addressing the findings will continue to produce blocked rounds.
🤖 This review was automatically generated with Coder Agents.
Responses to the remaining API review findings:
|
|
/coder-agents-review |
There was a problem hiding this comment.
Review blocked (R7). Author responded to 6 of 7 remaining findings. DEREM-18 (redundant index idx_user_ai_provider_keys_user_id) is still unaddressed.
Author response summary:
- DEREM-10 (P2): Contested. Generic 500s are intentional to avoid exposing DB details. Logging offered as follow-up.
- DEREM-11 (P2): Claims fixed (BaseURL validation test added in a73506515). Panel will verify whether this covers the original finding (update-rename-to-duplicate-name and invalid name).
- DEREM-12 (P3): Acknowledged. Empty-list behavior is a design choice for list semantics.
- DEREM-13 (P3): Acknowledged. Ownership check exists, accepts missing dedicated test.
- DEREM-14 (P3): Acknowledged. Indirect coverage via lifecycle tests.
- DEREM-15 (P3): Acknowledged. Idempotent delete is intentional.
- DEREM-18 (Nit): Still silent.
One Nit remains unaddressed. A brief response to DEREM-18 (even "will not change") unblocks the panel round, which will evaluate the contested DEREM-10 and verify the acknowledged findings.
🤖 This review was automatically generated with Coder Agents.
|
/coder-agents-review |
There was a problem hiding this comment.
Review blocked (R8). Identical state to R7. DEREM-18 (redundant idx_user_ai_provider_keys_user_id index, Nit severity) remains the sole blocker, now silent for 6 consecutive rounds.
All other findings have been addressed, contested, or acknowledged. The panel is ready to evaluate DEREM-10 (contested), verify DEREM-11, and review the acknowledged P3 findings. Only a one-line response to DEREM-18 is needed.
CI is also failing (test-go-pg, test-go-pg-17, test-go-race-pg).
🤖 This review was automatically generated with Coder Agents.
|
/coder-agents-review |
3 similar comments
|
/coder-agents-review |
|
/coder-agents-review |
|
/coder-agents-review |
There was a problem hiding this comment.
Panel review (R9, 4 reviewers: Bisky, Mafuuu, Chopper, Meruem). All R1 and most R2 findings verified fixed. Good progress across 8 rounds.
Severity count: 1 P1, 2 P2, 5 P3, 1 Nit.
The P1 is a CI blocker: GetAIProviderByIDForUpdate has no dbauthz test, and the method accounting suite will fail. The new P2 is an auth action mismatch on the same method (ActionRead instead of ActionUpdate).
DEREM-10 (contested): Panel evaluated the author's defense and agrees the generic response body is fine. The real gap is zero server-side logging across all 11 handlers. Panel re-raises at P2 (2/3 hold). This needs a human decision: either add api.Logger.Error calls to the error paths, or file a ticket for the logging follow-up.
DEREM-11 (reopened): The author's fix added UpdateRejectsInvalidBaseURL, which covers BaseURL validation. The original finding was about name validation on update (duplicate name 409, invalid name 400), which remains untested.
"A future caller uses GetAIProviderByIDForUpdate without handler-level authorization. The dbauthz layer permits it with only read permissions, allowing a read-only subject to acquire a FOR UPDATE row lock." (Meruem)
🤖 This review was automatically generated with Coder Agents.
There was a problem hiding this comment.
Review blocked (R10). DEREM-24 (P1, missing dbauthz test) addressed in 74a5622c1, which unblocks CI. However, the new test asserts ActionRead, codifying the behavior that DEREM-25 flags as incorrect (should be ActionUpdate per the GetChatProviderByIDForUpdate pattern).
8 findings remain silent:
- P2: DEREM-10 (panel re-raised: missing server-side logging), DEREM-11 (update name validation untested), DEREM-25 (ActionRead vs ActionUpdate)
- P3: DEREM-23 (update name error missing Detail), DEREM-26 (orphaned keys on soft-delete), DEREM-27 (empty key untested), DEREM-28 (upsert conflict untested)
- Nit: DEREM-29 (BaseURL assertion missing)
Further review is blocked until the author responds to the remaining findings.
🤖 This review was automatically generated with Coder Agents.
|
/coder-agents-review |
There was a problem hiding this comment.
Review blocked (R11). DEREM-11 (update name validation untested) and DEREM-25 (ActionRead→ActionUpdate) addressed in ff67953be. Good fixes.
6 findings remain silent:
- P2: DEREM-10 (panel re-raised: missing server-side logging; needs human decision or ticket)
- P3: DEREM-23 (update name error missing Detail), DEREM-26 (orphaned keys on soft-delete), DEREM-27 (empty key untested), DEREM-28 (upsert conflict untested)
- Nit: DEREM-29 (BaseURL assertion missing)
Note: the new UpdateRejectsInvalidName test asserts only Message, not Detail, which validates the current behavior flagged by DEREM-23 rather than fixing it.
Further review blocked until author responds to remaining findings.
🤖 This review was automatically generated with Coder Agents.
Responses to R11 remaining findings:
|
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: db255d3c49
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
db255d3 to
f67152c
Compare
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f67152c41e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
f67152c to
a7f9b7b
Compare
|
@codex review
|
a7f9b7b to
fbb18e6
Compare
bc87cca to
8c1df77
Compare
|
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Graphite StackThis PR is part of the
|
7badaf6 to
74e0956
Compare
8c1df77 to
06c0b16
Compare
6d13e03 to
97884ad
Compare
06c0b16 to
222d76b
Compare
222d76b to
96c06b6
Compare
97884ad to
bb8a97d
Compare
bb8a97d to
c7bf03a
Compare
96c06b6 to
e822a80
Compare
Closing this PR as obsolete because main now includes the AI provider REST API. The remaining stack has been rebased to use the main API instead. |
Stack Context
This PR builds on #25412 in the AI providers stack.
Stack order:
What?
Adds the AI provider chat API surface, SDK types and methods, authorization coverage, and API tests.
Validation
go test ./coderd -run '^(TestAIProviderCRUD|TestUserAIProviderKeys|TestListChatModelConfigs|TestCreateChatModelConfig|TestUpdateChatModelConfig|TestDeleteChatModelConfig)$' -count=1