fix(scripts): Fix "undefined Options: ..." in generated JSON schema for enum settings without descriptions.#2963
Open
chinesepowered wants to merge 1 commit intoQwenLM:mainfrom
Conversation
…ption schema.description is only assigned when setting.description is truthy. For enum settings missing a description, the subsequent += produced the literal string 'undefined Options: foo, bar' in the generated JSON schema. Initialize the field when absent instead of concatenating onto undefined.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix
"undefined Options: ..."in generated JSON schema for enum settings without descriptions.TLDR
scripts/generate-settings-schema.tsonly assignedschema.descriptionwhen the setting had a description, then appended enum options with+=. For enum settings missing a description, the+=ran againstundefinedand produced the literal string"undefined Options: foo, bar"in the generated JSON schema. This PR initializes the field cleanly instead of concatenating ontoundefined.Screenshots / Video Demo
Before (generated JSON schema entry):
{ "type": "string", "enum": ["fast", "accurate"], "description": "undefined Options: fast, accurate" }After:
{ "type": "string", "enum": ["fast", "accurate"], "description": "Options: fast, accurate" }Dive Deeper
convertSettingToJsonSchemainitializesschemaas an empty object, then conditionally assignsdescription:Later, for the
'enum'case:For any enum setting declared without a
description,schema.descriptionisundefinedat the point of+=, and JavaScript coerces to"undefined Options: fast, accurate".The fix initializes cleanly:
Settings that already had a description are unaffected — only the previously-broken
undefinedpath changes.Modified file:
scripts/generate-settings-schema.ts— initializeschema.descriptioncleanly for enumsReviewer Test Plan
pnpm tsx scripts/generate-settings-schema.ts(or whatever the project's generation command is)"undefined Options:"— should be emptypackages/cli/src/config/settingsSchema.ts) — verify it still reads"<original description> Options: ..."Testing Matrix