fix(settings): persist model allowlist as JSON array#518
fix(settings): persist model allowlist as JSON array#518cita-777 merged 1 commit intocita-777:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR refines the runtime settings system for global model and brand lists by updating persistence to store arrays directly, enhancing the hydration parser to handle JSON-encoded values and legacy double-encoded formats, and adding corresponding test coverage for normalization and database persistence behavior. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Summary
global_allowed_models.global_blocked_brands, which uses the same settings persistence path.Problem
Related to #301, which introduced the global model allowlist feature. This PR fixes a persistence encoding issue in that feature's runtime settings save path.
Runtime settings are persisted through
upsertSetting, which already serializes values withJSON.stringify.The model allowlist save path pre-serialized arrays before passing them to
upsertSetting, so the stored value became a JSON string containing an array instead of a JSON array. After export/import or restart hydration, this could be interpreted as a malformed model name list.Example bad persisted value:
"[\"model-alpha\",\"model-beta\"]"Expected persisted value:
Changes
upsertSettingfor:global_allowed_modelsglobal_blocked_brandsValidation
npm test -- src/server/routes/api/settings.events.test.ts src/server/runtimeSettingsHydration.test.tsResult:
Also verified with a local Docker deployment:
settings.valuestoresglobal_allowed_modelsas a JSON array/api/settings/runtimestill returns an arrayRisk
Low. The change is limited to runtime settings persistence and hydration for list values. Existing valid JSON arrays continue to work, and legacy double-encoded arrays are now accepted for compatibility.
Summary by CodeRabbit
Bug Fixes
Tests