Uh oh!
There was an error while loading. Please reload this page.
Support undefined, number in JSON module - #3980
Conversation
There was a problem hiding this comment.
Warning
- Copilot's review of this pull request may be incomplete because some of the changed files are excluded by your Copilot content exclusion settings. See Excluding content from Copilot for details.
Pull request overview
This PR extends the internal JSON schema-validation helpers to better distinguish “optional” vs “optional-or-null” fields, and to add first-class validators for number and object. It also updates start-proxy configuration schemas to use the new optionalOrNull semantics and adjusts unit tests accordingly.
Changes:
- Introduces
isNumber, plusjson.numberandjson.objectvalidators. - Renames the old “optional (undefined or null)” behavior to
optionalOrNulland redefinesoptionalto mean “undefined-only”. - Updates start-proxy schemas and unit tests to reflect the new optional semantics.
Show a summary per file
| File | Description |
|---|---|
| src/start-proxy/types.ts | Switches relevant schema fields from optional to optionalOrNull for backwards-compatible null acceptance. |
| src/json/index.ts | Adds number/object validators and splits optional handling into optionalOrNull vs optional. |
| src/json/index.test.ts | Updates/expands tests to cover the new optional semantics (optionalOrNull vs optional). |
| lib/entry-points.js | Generated output (content excluded from review per policy). |
Review details
Files excluded by content exclusion policy (1)
- lib/entry-points.js
- Files reviewed: 3/4 changed files
- Comments generated: 3
- Review effort level: Low
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| /** A validator for number fields in schemas. */ | ||
| export const number = { | ||
| validate: isNumber, | ||
| required: true, | ||
| } as const satisfies Validator<number>; |
These have been spun off into #3980.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
46563f5 to
2a939e7CompareThe previous implementation of `optional` is now `optionalOrNull`.
By @mbg Co-authored-by: Michael B. Gale <mbg@github.com>
5d92713 to
cbf67daCompareundefined, number, and object in JSON moduleundefined, number in JSON module
Summary
This pull request introduces several additions to the JSON schema-validation utilities:
optionalvalidator tooptionalOrNullto clarify that schema fields may be optional and acceptnullas a valid value, in addition toundefined.optionalvalidator so that it only acceptsundefined(notnull), making its behavior more precise and distinct fromoptionalOrNull.number.isNumbertype guard function for type checking.This PR is a prerequisite for #3950.
Risk assessment
For internal use only. Please select the risk level of this change:
Which use cases does this change impact?
Workflow types:
dynamicworkflows (Default Setup, Code Quality, ...).Products:
analysis-kinds: code-scanning.analysis-kinds: code-quality.Environments:
github.comand/or GitHub Enterprise Cloud with Data Residency.How did/will you validate this change?
.test.tsfiles).pr-checks).If something goes wrong after this change is released, what are the mitigation and rollback strategies?
How will you know if something goes wrong after this change is released?
Are there any special considerations for merging or releasing this change?
Merge / deployment checklist