Skip to content

Schema validation fails when items is a list. #34631

@Ionaru

Description

@Ionaru

Current Behavior

In JSON Schema draft 07 (2018), the "items" property can be a list and must be validated using tuple validation.

The validateProperty util in packages/nx/src/utils/params.ts currently does not support this, causing validation to fail with the error that the property does not match the schema (but it does).

Expected Behavior

A schema using JSON Schema draft 07 like https://github.com/angular/angular-cli/blob/15794dc101fffd49818545c4ab015a3bf238b14a/packages/angular/build/src/builders/unit-test/schema.json must be successfully parsed by the NX parser.

OR

The parser must give a clear error message that it does not support the given schema.

GitHub Repo

https://github.com/Ionaru/schema7fail

Steps to Reproduce

In https://github.com/Ionaru/schema7fail:

  1. Run npm install
  2. Run nx test my-app

Clean repro:

  1. Create an NX project with an Angular application
  2. In project.json add:
    "test": {
      "executor": "@angular/build:unit-test",
      "options": {
        "reporters": [["junit", {"suiteName": "MyApp"}]]
      }
    }
  1. Run nx test <app_name>

Nx Report

Node           : 24.14.0
OS             : win32-x64
Native Target  : x86_64-windows
npm            : 11.11.0

nx                     : 22.3.3
@nx/js                 : 22.3.3
@nx/eslint             : 22.3.3
@nx/workspace          : 22.3.3
@nx/angular            : 22.3.3
@nx/devkit             : 22.3.3
@nx/eslint-plugin      : 22.3.3
@nx/module-federation  : 22.3.3
@nx/playwright         : 22.3.3
@nx/plugin             : 22.3.3
@nx/rspack             : 22.3.3
@nx/vite               : 22.3.3
@nx/vitest             : 22.3.3
@nx/web                : 22.3.3
@nx/webpack            : 22.3.3
typescript             : 5.9.3

Failure Logs

NX   Property 'reporters' does not match the schema.
{
  "oneOf": [
    {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "enum": [
            "default",
            "verbose",
            "dots",
            "json",
            "junit",
            "tap",
            "tap-flat",
            "html"
          ]
        }
      ]
    },
    {
      "type": "array",
      "minItems": 1,
      "maxItems": 2,
      "items": [
        {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "enum": [
                "default",
                "verbose",
                "dots",
                "json",
                "junit",
                "tap",
                "tap-flat",
                "html"
              ]
            }
          ]
        },
        {
          "type": "object"
        }
      ]
    }
  ]
}'

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

Linked to angular/angular-cli#32618

Metadata

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions