修复/update-config 指令报错: Error: Undefined cannot be represented in JS…#1283
修复/update-config 指令报错: Error: Undefined cannot be represented in JS…#1283xiaoFjun-eng wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughIn ChangesSettings Schema Type Tightening
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/utils/settings/types.ts`:
- Line 571: The schema union at line 571 that validates enabledPlugins and
similar fields no longer accepts z.undefined() due to JSON Schema generation
conflicts, but the deletion semantics in updateSettingsForSource and
validateSettingsFileContent still expect to pass undefined values for field
deletion. Align this contract by filtering out undefined entries from the record
object before it reaches schema validation in validateSettingsFileContent, so
that the strict schema validation succeeds while preserving the deletion
semantics that rely on detecting undefined values in the update logic.
Alternatively, update the deletion logic in updateSettingsForSource to detect
and handle deletions differently (without relying on undefined values) before
validation occurs.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 711960d9-dfc9-408d-9547-71fd0e327832
📒 Files selected for processing (1)
src/utils/settings/types.ts
| .record( | ||
| z.string(), | ||
| z.union([z.array(z.string()), z.boolean(), z.undefined()]), | ||
| z.union([z.array(z.string()), z.boolean()]), // , z.undefined() 导致报错:Undefined cannot be represented in JSON Schema |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Schema/value contract now conflicts with record-key deletion semantics (Line 571).
Removing z.undefined() here breaks the documented delete-by-undefined path for record fields (including enabledPlugins), and strict validation will now reject those in-flight values. This creates a cross-file contract break between SettingsSchema and updateSettingsForSource/validateSettingsFileContent.
Consider aligning the contract in the same PR: either (a) migrate deletion semantics away from explicit undefined values before validation/serialization, or (b) strip undefined record entries pre-parse so strict schema validation still succeeds while keeping JSON Schema generation valid.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/utils/settings/types.ts` at line 571, The schema union at line 571 that
validates enabledPlugins and similar fields no longer accepts z.undefined() due
to JSON Schema generation conflicts, but the deletion semantics in
updateSettingsForSource and validateSettingsFileContent still expect to pass
undefined values for field deletion. Align this contract by filtering out
undefined entries from the record object before it reaches schema validation in
validateSettingsFileContent, so that the strict schema validation succeeds while
preserving the deletion semantics that rely on detecting undefined values in the
update logic. Alternatively, update the deletion logic in
updateSettingsForSource to detect and handle deletions differently (without
relying on undefined values) before validation occurs.
…ON Schema。
Summary by CodeRabbit