Repository navigation
fix(api): refuse an empty enabled_providers list on config writes - #1656
Conversation
An empty list means "show every provider" to the recommendation readers but "collect from none" to the scheduler. PUT /api/config now returns 400 when the body carries enabled_providers (any key casing, null included) and the merged value is empty. Presence-based, so partial saves that omit the key still work on a fresh install that stores []. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 47 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. CodeRabbit Verify
|
…n cases Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent review 2 (claude-fleet, cold): APPROVE 86b8966 I reviewed this cold, on exports of 86b8966 and its merge base b139db1, treating the PR body as a claim. Checked
Non-blockingNone. Main's red checks (the frontend date test and the x/crypto scan) are unrelated to this diff. Not merging. |
|
Independent cold review A (claude-cc-platform's reviewer agent, did not write the change): APPROVE at What I attacked:
Pass 1 found that the refusal tests didn't assert the 400 code and didn't cover the duplicate-key or no-permission cases. a64c9e6 adds all three. One older issue the diff doesn't touch is filed as #1658: the Local verification (macOS, at 86b8966; a64c9e6 adds tests only): |
|
Local verification at
CodeRabbit hit its review rate limit on this PR and left no findings. |
|
Independent review 2 (claude-fleet, cold): APPROVE a64c9e6 Delta review of 86b8966..a64c9e6, on top of my APPROVE at 86b8966. The delta is test-only: Checked (at a64c9e6)
Non-blockingNone. Not merging. |
Follow-up to #1531. #1542 made the Settings form refuse a save that leaves no provider enabled. The API still accepted one. Per the owner's decision,
PUT /api/confignow refuses it too.What changes
updateConfig(internal/api/handler_config.go) returns 400enabled_providers must list at least one providerwhen the body carriesenabled_providersand it decodes to an empty list. That covers[],null, and any key casingjson.Unmarshalaccepts. The refusal runs inside the locked read-modify-write, so nothing is saved, and it comes before the arming-grant checks.GlobalConfig.Validate. A fresh install stores[], and every partial save that leaves the key out keeps working. The same reasoning is whyri_exchange_modeis checked only when sent.enabled_providersstates the write rule. It has nominItems, because a GET on a fresh install can still return[].Why the two meanings matter: an empty list means "every provider" to the recommendation readers (
handler_recommendations.go~195-216), but "collect from none" to the scheduler (scheduler.go~334).Breaking change
An API client that cleared every provider with
"enabled_providers": []now gets a 400.Tests
TestHandler_updateConfig_EnabledProvidersWritecovers five cases:[],nulland a mixed-case key are refused with no save.[]row is accepted.["aws"]is accepted.With the handler change reverted, the three refusal cases fail.
🤖 Generated with Claude Code