-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid JSON Schema enforcement of additionalProperties #22349
Comments
I believe this affects linting. The library or application with project.json without "targets": {
...
"lint": {
"executor": "@nx/eslint:lint"
},
...
} will trigger this error when
|
yes it fails for me as well
in this line https://github.com/nrwl/nx/blob/master/packages/nx/src/utils/params.ts#L293 |
This breaks any usage of @robertIsaac I tried your workaround, the error no longer appeared but the environment variables were not present for the running command |
This also breaks the usage of the new |
Running in to the same error as @mattfysh, holistically it surprises me that there is an additionalProperties field on the schema and not a properties field. I think the bug creeped in because of that reason (someone assuming a Reverting to |
Running into the same issue with the The issue exists since 18.1.0-beta.1 {
// ...
"serve": {
"executor": "@angular-devkit/build-angular:dev-server",
"options": {
// ...
"headers": {
"foo": "bar"
}
}
}
} $ pnpm nx serve <app> --verbose
TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at node_modules/nx/src/utils/params.js:194:24
at Array.find (<anonymous>)
at validateObject (node_modules/nx/src/utils/params.js:193:27)
at validateProperty (node_modules/nx/src/utils/params.js:346:9)
at node_modules/nx/src/utils/params.js:210:9
at Array.forEach (<anonymous>)
at validateObject (node_modules/nx/src/utils/params.js:209:23)
at validateOptsAgainstSchema (node_modules/nx/src/utils/params.js:144:5)
at combineOptionsForExecutor (node_modules/nx/src/utils/params.js:432:5) |
same issue here TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at /Users/noelsoong/Workspace/iticket-stack/node_modules/.pnpm/[email protected]/node_modules/nx/src/utils/params.js:194:24
at Array.find (<anonymous>)
at validateObject (/Users/noelsoong/Workspace/iticket-stack/node_modules/.pnpm/[email protected]/node_modules/nx/src/utils/params.js:193:27)
at validateProperty (/Users/noelsoong/Workspace/iticket-stack/node_modules/.pnpm/[email protected]/node_modules/nx/src/utils/params.js:346:9)
at /Users/noelsoong/Workspace/iticket-stack/node_modules/.pnpm/[email protected]/node_modules/nx/src/utils/params.js:210:9
at Array.forEach (<anonymous>)
at validateObject (/Users/noelsoong/Workspace/iticket-stack/node_modules/.pnpm/[email protected]/node_modules/nx/src/utils/params.js:209:23)
at validateOptsAgainstSchema (/Users/noelsoong/Workspace/iticket-stack/node_modules/.pnpm/[email protected]/node_modules/nx/src/utils/params.js:144:5)
at combineOptionsForExecutor (/Users/noelsoong/Workspace/iticket-stack/node_modules/.pnpm/[email protected]/node_modules/nx/src/utils/params.js:432:5) |
Anyone who is running into this error, were you able to track down which option was causing it? For me it was the If you apply the fix (see #22426 - use patch-package, pnpm patch, or edit the node_modules folder directly), does the error go away? If yes, is the option that triggered the error being applied or ignored? In the case of |
Also an issue with our internal plugins. Any ETA? |
I actually have no configuration at all "plugins": [
{
"plugin": "@nx/eslint/plugin",
"options": {
"targetName": "lint"
}
},
... |
@robertIsaac in the case of plugins, they are generating configuration for you you can see this by running |
I wish to include my custom flag (-t example) when executing the nx angular serve command. However, I encounter an error from nx indicating:
I intend to intercept this flag within proxy.mjs and handle it accordingly. What steps should I take to pass this argument without encountering an error? |
aha I see
so env was the cause |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Current Behavior
A executor schema that allows an object with arbitrary keys so long as the values match.
Typescript equivalent:
Record<{ foo: Record<string, number> }>
Running the executor throws with
Expected Behavior
Executor can run successfully. Schema is treated as valid.
GitHub Repo
No response
Steps to Reproduce
"type": "object"
with"additionalProperties"
set to anything but true.Nx Report
Failure Logs
Package Manager Version
pnpm 8.15.4
Operating System
Additional Information
Offending logic is right where the error logs point us: https://github.com/nrwl/nx/blob/master/packages/nx/src/utils/params.ts#L293
If
additionalProperties
is found, the logic attempts to get the keys ofproperties
. However there is no guarantee that value exists, andObject.keys(undefined)
is an error.The JSONSchema spec does not specify that
properties
must be set in order to useadditionalProperties
(as a general rule of thumb, no fields allow/disallow others).This logic should default
properties
to{}
in the case where it does not exist.Alternatively, I recommend switching to a battle tested JSON Schema validator, such as AJV
The text was updated successfully, but these errors were encountered: