Skip to content

fix: check resolved host requirement capability names at job creation - #371

Merged
mwiebe merged 1 commit into
OpenJobDescription:mainlinefrom
mwiebe:fix-capability-name-resolution
Sep 25, 2026
Merged

mwiebe merged 1 commit into
OpenJobDescription:mainlinefrom
mwiebe:fix-capability-name-resolution

Conversation

@mwiebe

@mwiebe mwiebe commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Fixes: OpenJobDescription/openjd-specifications#189

What was the problem/requirement? (What/Why)

OpenJobDescription/openjd-specifications#189 records that a host requirement amount or attribute name is a format string, and that its constraints apply to the resolved name. That includes the 100-character limit and the rule that no two amounts, and no two attributes, share a name.

Template validation only checks the raw names, and job creation didn't re-check the resolved ones. So a job was created in two cases:

  • two different format strings resolved to the same name, such as {{Param.A}} and {{Param.B}} both resolving to attr.custom.x;
  • a name resolved to more than 100 characters.

Four of the new conformance fixtures in openjd-specifications#189 fail because of this.

What was the solution? (How)

At job creation, in the pure-Python model:

  • AmountRequirement and AttributeRequirement check the 100-character limit on the resolved name.
  • HostRequirements checks that resolved names are unique within amounts and within attributes, ignoring case.

The error messages are the same ones already produced for literal names.

What is the impact of this change?

Job creation now rejects templates whose host requirement names, once resolved, are too long or duplicated. Templates that previously created a valid job are unaffected.

How was this change tested?

  • Added tests in test/openjd/model_v0/test_create_job.py that assert the full error message for:

    • duplicate resolved attribute names (case-insensitive) and duplicate resolved amount names;
    • attribute and amount names that resolve to 101 characters.

    They also cover the valid boundary: distinct resolved names, and names that resolve to exactly 100 characters.

  • The full test suite passes (hatch run test equivalent, 94% coverage gate met), and black, ruff and mypy are clean.

  • Ran the conformance suite from openjd-specifications#189 with openjd-cli using this build of openjd-model:

    • all 17 new fixtures pass (13 passed without this change);
    • the full suite passes.

Was this change documented?

Yes. The new checks have comments that reference the spec sections.

Is this a breaking change?

No. Templates that are only rejected now could never have produced a job that satisfies the specification.

Does this change impact security?

No.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

The capability name constraints and the uniqueness of names within
hostRequirements amounts and attributes apply to the names after their
format strings are resolved (OpenJobDescription/openjd-specifications#189).
Template validation only compares the raw names, so two different format
strings that resolved to the same name, or a name that resolved to more
than 100 characters, created a job.

Check the 100-character limit on the resolved amount and attribute names,
and the case-insensitive uniqueness of the resolved names, when the job is
created. The messages match the ones for literal names.

Signed-off-by: Mark <399551+mwiebe@users.noreply.github.com>
@mwiebe
mwiebe requested a review from a team as a code owner September 24, 2026 23:27
Comment thread src/openjd/model/v2023_09/_model.py
Comment thread src/openjd/model/v2023_09/_model.py
@mwiebe
mwiebe enabled auto-merge (rebase) September 25, 2026 00:34
@mwiebe
mwiebe merged commit 4d7f9b4 into OpenJobDescription:mainline Sep 25, 2026
32 checks passed
@mwiebe
mwiebe deleted the fix-capability-name-resolution branch September 25, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants