Skip to content

Create unique error message when state.find_name returns more than one match - #63673

Open
rhodesn wants to merge 3 commits into
saltstack:masterfrom
rhodesn:duplicate-requisite-id
Open

Create unique error message when state.find_name returns more than one match#63673
rhodesn wants to merge 3 commits into
saltstack:masterfrom
rhodesn:duplicate-requisite-id

Conversation

@rhodesn

@rhodesn rhodesn commented Feb 8, 2023

Copy link
Copy Markdown
Contributor

What does this PR do?

Updates the error message returned when users try to setup a requisite against an ID that appears multiple times within a highstate.

What issues does this PR fix or reference?

Fixes:

Previous Behavior

The previous error message was:

local:
    Data failed to compile:
----------
    Cannot extend ID 'bob' in 'base:common'. It is not part of the high state.
This is likely due to a missing include statement or an incorrectly typed ID.
Ensure that a state with an ID of 'bob' is available
in environment 'base' and to SLS 'common'

New Behavior

local:
    Data failed to compile:
----------
    Cannot extend ID 'bob' in 'base:common'. It is not unique in the running high state.
This is likely due to more than one state using the same `name` parameter. Ensure that
the state with an ID of 'bob' is unique in environment 'base' and to SLS 'common'.
Duplicate states IDs are: 'user: my-test-user, user: another_user'

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

No

Please review Salt's Contributing Guide for best practices.

See GitHub's page on GPG signing for more information about signing commits with GPG.

@rhodesn
rhodesn requested a review from a team as a code owner February 8, 2023 16:47
@rhodesn
rhodesn requested review from MKLeb and removed request for a team February 8, 2023 16:47
@dwoz

dwoz commented Dec 12, 2023

Copy link
Copy Markdown
Contributor

@nrhodes91 This needs a changelog file, thanks.

@dwoz dwoz added this to the Argon v3008.0 milestone Dec 12, 2023
@dwoz
dwoz requested a review from a team as a code owner March 16, 2025 22:09

@twangboy twangboy 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.

This needs a changelog and some tests

@twangboy twangboy 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.

This looks great. Could we get a changelog and a test please?

@twangboy twangboy added needs-testcase PR needs test cases written, or the issue is about a bug/feature that needs test cases test:pkg Run the package tests labels Jul 3, 2025
rhodesn and others added 3 commits June 15, 2026 16:35
…e match

It's possible for `state.find_name()` to return more than one match for a state ID, e.g. when a user
has their groups modified by multiple states (`remove_groups: false`). If a state then tried to
reference that user via their name:

```
testfile:
  file.managed:
    [...]
    - require_in:
      - user: nobody
```
Multiple states could match the requisite. The PR updates the error message returned when this
happens to explicitly state that there are multiple states for that ID, and hence it's not possible
to create the requisite.
@dwoz
dwoz force-pushed the duplicate-requisite-id branch from 36794dc to 5a63fdc Compare June 15, 2026 23:36
@dwoz dwoz added test:full Run the full test suite and removed needs-testcase PR needs test cases written, or the issue is about a bug/feature that needs test cases labels Jun 15, 2026
@dwoz dwoz modified the milestones: Argon v3008.1, Potassium v3009.0 Jun 15, 2026
@twangboy

Copy link
Copy Markdown
Contributor

If this is a bug, it should probably go against 3006.x

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

Labels

test:full Run the full test suite test:pkg Run the package tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants