fix(py-ext-marketplace): gate seen_names mutation on validate_bundle duplicate path#2161
Merged
imran-siddique merged 1 commit intoMay 12, 2026
Conversation
…duplicate path
`BundleRegistry.validate_bundle` recorded every component name in
``seen_names`` regardless of whether the duplicate check had already fired:
if comp.name in seen_names:
errors.append(f"Duplicate component name: {comp.name!r}")
seen_names.add(comp.name) # also runs on duplicates
Re-adding an already-present name to a ``set`` is a no-op, so this didn't
change which duplicate errors got emitted — every repeat-occurrence still
reports correctly. The defect is cosmetic in the strict sense, but two
related problems were real:
1. **Empty names polluted ``seen_names``**: a ``BundleComponent`` with
``name == ""`` had its empty string added to ``seen_names``, so the
*next* unnamed component would be reported BOTH as
"Component name is required" AND as `Duplicate component name: ''` —
a spurious second finding for the same underlying problem.
2. **Loop intent was implicit**: ``seen_names`` is meant to mean
"canonical / first-seen names". Adding to it on the duplicate branch
hid that contract behind a set-semantics quirk.
This change gates ``seen_names.add(comp.name)`` behind ``not in seen_names``
and skips the add entirely for empty names. Both adjustments are
locally-scoped to the duplicate-tracking branch; the "name required" and
"version required" findings are unchanged.
Regression tests:
- Three components sharing the same name now emit two `Duplicate` errors
(one per repeat occurrence).
- Two unnamed components emit two "Component name is required" findings
and zero `Duplicate component name: ''` findings.
Surfaced during independent audit conducted by @finnoybu (Ken Tannenbaum, AEGIS Initiative); [LOW, Python Extensions].
🤖 AI Agent: code-reviewer — View detailsTL;DR: 0 blockers, 0 warnings. No issues found. Clean change. |
🤖 AI Agent: breaking-change-detector — API CompatibilityAPI Compatibility
|
🤖 AI Agent: docs-sync-checker — Docs SyncDocs Sync
Please address these issues to ensure documentation is in sync. |
🤖 AI Agent: test-generator — `workflow_bundle.py`
|
🤖 AI Agent: security-scanner — View detailsNo security issues found. |
|
🟡 Contributor Check: MEDIUM
Automated check by AGT Contributor Check. |
PR Review Summary
Verdict: ✅ Ready for human review |
MohammadHaroonAbuomar
pushed a commit
to MohammadHaroonAbuomar/agt-acs
that referenced
this pull request
Jun 1, 2026
…duplicate path (microsoft#2161) `BundleRegistry.validate_bundle` recorded every component name in ``seen_names`` regardless of whether the duplicate check had already fired: if comp.name in seen_names: errors.append(f"Duplicate component name: {comp.name!r}") seen_names.add(comp.name) # also runs on duplicates Re-adding an already-present name to a ``set`` is a no-op, so this didn't change which duplicate errors got emitted — every repeat-occurrence still reports correctly. The defect is cosmetic in the strict sense, but two related problems were real: 1. **Empty names polluted ``seen_names``**: a ``BundleComponent`` with ``name == ""`` had its empty string added to ``seen_names``, so the *next* unnamed component would be reported BOTH as "Component name is required" AND as `Duplicate component name: ''` — a spurious second finding for the same underlying problem. 2. **Loop intent was implicit**: ``seen_names`` is meant to mean "canonical / first-seen names". Adding to it on the duplicate branch hid that contract behind a set-semantics quirk. This change gates ``seen_names.add(comp.name)`` behind ``not in seen_names`` and skips the add entirely for empty names. Both adjustments are locally-scoped to the duplicate-tracking branch; the "name required" and "version required" findings are unchanged. Regression tests: - Three components sharing the same name now emit two `Duplicate` errors (one per repeat occurrence). - Two unnamed components emit two "Component name is required" findings and zero `Duplicate component name: ''` findings. Surfaced during independent audit conducted by @finnoybu (Ken Tannenbaum, AEGIS Initiative); [LOW, Python Extensions].
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.
Summary
BundleRegistry.validate_bundlerecorded every component name inseen_namesregardless of whether the duplicate check had already fired:Re-adding an already-present name to a
setis a no-op, so this didn't change which duplicate errors got emitted — every repeat occurrence still reports correctly. The defect is cosmetic in the strict sense, but two related problems were real:seen_names. ABundleComponentwithname == ""had its empty string added toseen_names, so the next unnamed component would be reported BOTH as"Component name is required"AND asDuplicate component name: ''— a spurious second finding for the same underlying problem.seen_namesis meant to mean "canonical / first-seen names". Adding to it on the duplicate branch hid that contract behind a set-semantics quirk.Change
Gate
seen_names.add(comp.name)behindnot in seen_namesand skip the add entirely for empty names. Both adjustments are locally-scoped to the duplicate-tracking branch; the existing "name required" and "version required" findings are unchanged.Tests
Two new regression tests in
tests/test_workflow_bundle.py::TestValidateBundle:test_three_components_same_name_emit_two_duplicates— three components sharing one name yield twoDuplicateerrors.test_unnamed_components_do_not_cross_collide_as_duplicates— two unnamed components yield two"Component name is required"findings and zeroDuplicatefindings.Test plan
Surfaced during independent audit conducted by @finnoybu (Ken Tannenbaum, AEGIS Initiative); [LOW, Python Extensions].