Skip to content

fix!: require attribute and amount names to be unique#265

Merged
crowecawcaw merged 2 commits intoOpenJobDescription:mainlinefrom
crowecawcaw:fix-amount-attribute-uniqueness
Mar 4, 2026
Merged

fix!: require attribute and amount names to be unique#265
crowecawcaw merged 2 commits intoOpenJobDescription:mainlinefrom
crowecawcaw:fix-amount-attribute-uniqueness

Conversation

@crowecawcaw
Copy link
Contributor

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

The amount and attribute names in host requirements are not required to be unique at the moment; duplicate names are allowed. Multiple requirements with the same name is non-sensical though and should be rejected.

Related OpenJD spec PR: OpenJobDescription/openjd-specifications#110

While updating the test, I noticed existing test was incorrectly set up and testing the wrong data model. Since the test just looked for failures, the test passed but the validation failures were for the wrong reason. I made the test more specific to ensure it's testing what we think we're testing.

There are other tests that make similar mistakes and will also need to be updated. Future work.

What was the solution? (How)

Reject a template if a step's host requirements has duplicated attribute or amount names.

What is the impact of this change?

Closes a undefined behavior gap.

How was this change tested?

Unit tests

Was this change documented?

n/a

Is this a breaking change?

Technically yes, but practically no. Duplicated requirements do not have a clear behavior, and templates with duplicates are likely buggy. Marking the PR with fix! to indicate a minor version bump is recommended.

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.

Signed-off-by: Stephen Crowe <6042774+crowecawcaw@users.noreply.github.com>
pytest.param(
{
"amounts": [
{"name": "amount.mycap", "min": 1},
Copy link

Choose a reason for hiding this comment

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

Does the openjd spec allow this or specify properties w/ different cases are duplicates ?

Copy link

Choose a reason for hiding this comment

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

Trying to find it in the spec and it escapes me right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@crowecawcaw crowecawcaw enabled auto-merge (squash) March 4, 2026 20:22
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 4, 2026

@crowecawcaw crowecawcaw merged commit c5ba60e into OpenJobDescription:mainline Mar 4, 2026
25 checks passed
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