Skip to content

test(2.0): move root components in invalid fixtures to the 2.0 layout - #1251

Merged
jkowalleck merged 1 commit into
CycloneDX:2.0-devfrom
Mehrn0ush:fix/2.0-invalid-fixtures-root-components
Nov 25, 2026
Merged

jkowalleck merged 1 commit into
CycloneDX:2.0-devfrom
Mehrn0ush:fix/2.0-invalid-fixtures-root-components

Conversation

@Mehrn0ush

Copy link
Copy Markdown
Contributor

Problem

Nine invalid 2.0 test fixtures still put components at the root of the BOM. The 2.0 root schema has no root components property and sets unevaluatedProperties: false, so every one of them is rejected with must NOT have unevaluated properties [components] before the schema ever checks the defect the fixture was written for.

The suites pass because they only check that an invalid fixture is rejected, not why it is rejected. As a result, these fixtures don't test anything:if the constraint each one targets were removed or broken, the fixture would still be rejected and the tests would stay green.

The fixtures came in with the AI/ML and measurements work merged in 3714a38. In that merge, the matching valid fixtures (valid-ai-ml-*, valid-measurements-2.0.json, valid-cryptography-protocol-type-2.0.json) were moved to the 2.0 layout, but these invalid ones were not.

Change

Each fixture's components array moves to where its valid sibling puts it:

Fixture New location Intended defect
invalid-ai-ml-energy-unit-2.0.json definitions.components energyunit MWh is not an allowed energy unit
invalid-ai-ml-energy-unit-object-2.0.json definitions.components energy unit given as an object
invalid-ai-ml-legacy-modelcard-2.0.json definitions.components 1.x modelCard on a component
invalid-ai-ml-task-casing-2.0.json definitions.components task Summarization (wrong casing)
invalid-ai-ml-unit-custom-missing-name-2.0.json definitions.components custom unit without name
invalid-ai-ml-unit-unknown-symbol-2.0.json definitions.components unknown unit symbol furlongs
invalid-custom-unit-rec20-code-2.0.json definitions.components unece-rec20 code that is not a REC 20 code
invalid-measure-unit-missing-2.0.json definitions.components activityEnergyCost without unit
invalid-cryptography-protocol-type-2.0.json inventories[0].components, with the same subject as valid-cryptography-protocol-type-2.0.json protocol type: "other"

The component objects and all other content are unchanged. The line diff is large only because the moved arrays are re-indented; git diff -w shows the structural change.

invalid-inventory-old-root-components-2.0.json is intentionally left alone: root components is the defect it tests.

Verification

  • Content preserved: for each file, the moved components array deep-equals the original, and the rest of the document deep-equals the original minus components.
  • Positive control: each fixture is rejected as committed and becomes valid once its one intended defect is repaired (e.g. MWh to kWh, other to tls, Summarization to summarization). The same check against thecurrent 2.0-dev fixtures fails for all nine: they stay invalid after therepair, because root components still rejects them.
  • **JS test:v2.0, including the bundled schemas (TEST_BUNDLED=true):**the validate, semantic and functional suites pass with 0 errors.
  • Java schema-v2.0: 318 tests, 0 failures, 0 errors.
  • PHP: not run locally. Its suite checks only that each invalid fixture is rejected, which is still true.

Not in this PR

invalid-formulation-envVars-2.0.json also has root components, and hascomponents inside formulation[0] as well. It already fails for its intended reason (environmentVars), so it is not a no-op test, and I left it out to keep this change mechanical.

Separately, the suites could assert the expected error for each invalid fixture, which would catch this kind of drift automatically. That is a largerchange to the test harness.

Thanks @bhess

Nine invalid 2.0 fixtures still placed components at the BOM root, which the 2.0 root schema rejects via unevaluatedProperties. They were therefore rejected before the constraint each one targets was evaluated. Move their components to definitions.components or inventories[0].components, matching their valid siblings. No other content changes.

Signed-off-by: Mehrn0ush <[email protected]>
@Mehrn0ush
Mehrn0ush requested a review from a team as a code owner November 24, 2026 11:15
@jkowalleck jkowalleck added the CDX 2.0 related to release v2.0 label Nov 24, 2026
@jkowalleck jkowalleck added this to the 2.0 milestone Nov 24, 2026
@jkowalleck jkowalleck added test-data related to test-resources and -data defect labels Nov 24, 2026

@bhess bhess left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Mehrn0ush , I've looked mainly at the crypto-related one and this one looks good to me.

@jkowalleck
jkowalleck merged commit 5197d88 into CycloneDX:2.0-dev Nov 25, 2026
41 of 49 checks passed
@jkowalleck

Copy link
Copy Markdown
Member

thank you so much for fixing these misleading and wrong negative/invalid examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CDX 2.0 related to release v2.0 defect test-data related to test-resources and -data

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants