-
fix(devkit): allow null values in JSON schema validation (#34167)
发布于
2026-01-23 20:09:09 +00:00 Current Behavior
Schema validation (done, for instance, when calling an executor) fails
when an option has value "null" and schema accepts null values. I had it
in a custom executor fornx-release-publish, that understands that
nxReleaseVersionDatais implicitly passed, so I define its schema:"newVersion": { "type": ["string", "null"], "description": "The new version of the project, null if no changes detected" }My code calls
getReleaseClient().releaseVersion(options), which gets
me aprojectsVersionDataobject with version info. It containsnull
values (allowed). I then pass it, and ends up in:// nx/src/tasks-runner/task-orchestrator.ts:531-539 const combinedOptions = combineOptionsForExecutor( task.overrides, // ← Contains nxReleaseVersionData with null values task.target.configuration, targetConfiguration, schema, // ← Schema from executor task.target.project, relativeCwd, isVerbose );which fails inside:
// nx/src/utils/params.js:126-201 function validateObject(opts, schema, definitions) { // Line 191-200: Iterate through all properties Object.keys(opts).forEach((p) => { validateProperty( p, // "nxReleaseVersionData" opts[p], // { foo: { newVersion: null, ... }} (schema.properties ?? {})[p], // schema for nxReleaseVersionData definitions ); }); }Expected Behavior
nullvalues should be considered, as they are valid in JSON schemas. It was probably not considered, because we never think thattypeof null === "object", but it's unfortunately the case.Related Issue(s)
I will create one
下载附件