Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/utils/settings/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ export const SettingsSchema = lazySchema(() =>
enabledPlugins: z
.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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ 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.

)
.optional()
.describe(
Expand Down
Loading