Repository navigation
Reject attribute-condition configuration that resolves to no entry or several - #53081
Open
antoniocasagrande-airia wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Duplicate-key multiline input still bypasses the new guard.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Hardens workflow attribute-condition parsing to reject invalid property cardinality.
Changes:
- Requires one parsed property.
- Adds parsing and rejection tests.
| File | Description |
|---|---|
UserAttributeWorkflowConditionProvider.java |
Adds cardinality validation. |
UserAttributeWorkflowConditionProviderTest.java |
Covers accepted and rejected inputs. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
… several parseKeyValuePair loads the configuration through Properties, which is the format the documentation specifies, but two shapes get past it and both make a condition match a resource set that was never configured: - No entry at all, when the input is empty or its key is one Properties reads as a '#' or '!' comment. stringPropertyNames().iterator().next() then raises a bare NoSuchElementException rather than the WorkflowInvalidStateException the method already throws a few lines earlier. - More than one entry, from multi-line input. Properties is a Hashtable, so the iterator picks an arbitrary entry and a stray newline silently selects a different attribute than the intended one. Require exactly one entry. No valid configuration changes meaning: both documented separators, presence-only keys, comma-separated values and escaped separators all parse as before, and only input that previously crashed or resolved arbitrarily is now rejected. Fixed in the shared helper rather than in one condition, so has-user-attribute and has-client-attribute keep identical configuration semantics. Signed-off-by: Antonio Casagrande <antoniocasagrande@airia.com>
Properties keeps one entry per key, so "plan=gold\nplan=silver" left size() at one and the guard accepted it, resolving silently to the last value. Count entries as they load instead, and pin the repeated-key case in the test. Signed-off-by: Antonio Casagrande <antoniocasagrande@airia.com>
antoniocasagrande-airia
force-pushed
the
workflow-attribute-condition-config-validation
branch
from
October 14, 2026 18:02
bc42ad0 to
17859a9
Compare
Contributor
|
@antoniocasagrande-airia I want to pick this up - sorry for the delay, its been really busy these past couple of months. I've opened #55757 to track this as we require the PRs to have an issue they close. Can you rebase than edit your commit and PR description to include "Closes #55757"? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


UserAttributeWorkflowConditionProvider.parseKeyValuePairloads a condition's configuration throughProperties, which is the format the documentation specifies. Two shapes get past it, and both leave a condition matching a resource set that was never configured.No entry at all — the input is empty, or its key is one
Propertiesreads as a#or!comment.stringPropertyNames().iterator().next()then raises a bareNoSuchElementExceptionrather than theWorkflowInvalidStateExceptionthe method already throws a few lines earlier.More than one entry, from multi-line input.
Propertiesis aHashtable, so the iterator resolves to an arbitrary entry and a stray newline silently selects a different attribute than the intended one. A key repeated on a second line is the same problem in another form:Propertieskeeps one entry per key and the last value wins, so entries are counted as they load rather than read back withsize().This requires exactly one entry. No valid configuration changes meaning: presence-only keys, both documented separators, comma-separated values and escaped separators all parse as before — only input that previously crashed or resolved arbitrarily is now rejected. That also completes the "a single param for each condition" invariant #43716 set out to establish.
Fixed in the shared helper rather than in one condition, so
has-user-attributeand the client-attribute condition being added in #52189 keep identical configuration semantics.Testing
New unit test in
model/jpa. It pins the accepted grammar (both documented separators, presence-only keys, comma-separated values, escaped separators) as well as the two rejections, so the fix cannot narrow what already works.Verified locally:
mvn -pl model/jpa -am test -Dtest=UserAttributeWorkflowConditionProviderTestpasses 8/8, andmvn spotless:check -pl model/jpais clean. I also confirmed the tests fail without the fix — reverting the guard reproduces theNoSuchElementExceptionon the no-entry cases and silently accepts the multi-line ones, and counting withsize()instead fails only the repeated-key case.Context: this was originally part of #51629, which I have closed; the condition work there is superseded by #52189. This half is an independent fix to shipped code, so it is on its own.