fix(extensions): reject aliases that shadow core commands - #4558
Open
chelsealong wants to merge 1 commit into
Open
fix(extensions): reject aliases that shadow core commands#4558chelsealong wants to merge 1 commit into
chelsealong wants to merge 1 commit into
Conversation
_validate_install_conflicts only compared declared command/alias names against installed extensions, never against core command names, so an extension could claim a core command's fully-qualified name (e.g. 'speckit.taskstoissues') as an alias and shadow it silently. Primary names are already namespace-checked against CORE_COMMAND_NAMES, but aliases are intentionally free-form, so this can only be caught in the install-conflict check by comparing against the qualified core names directly. Fixes github#4555
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
Fixes #4555.
_validate_install_conflictsis documented as rejecting installs that "would shadow core or installed extension commands", but_get_installed_command_name_maponly walksself.registry— installed extensions. Core command names were never in the map it consults, so an extension could declare a core command's fully-qualified name (e.g.speckit.taskstoissues) as an alias and install successfully, shadowing the core command.Primary command names are already namespace-checked against
CORE_COMMAND_NAMESin_collect_manifest_command_names(a primary name likespeckit.taskstoissuesis correctly rejected — it fails the required two-segmentspeckit.{extension}.{command}pattern). Aliases are intentionally free-form (existing community extensions use short aliases likespeckit.verify), so they can't be pattern-checked the same way — the only safe fix is to compare declared alias names directly against the fully-qualified core command names in the install-conflict check.Fix
In
_validate_install_conflicts(src/specify_cli/extensions/__init__.py), buildcore_command_namesfromCORE_COMMAND_NAMES(qualified asspeckit.<name>) and reject any declared command/alias name that matches, in addition to the existing installed-extension check.Test plan
test_install_rejects_alias_shadowing_core_commandtotests/test_extensions.py, reproducing the exact scenario from the issue: a manifest declaringspeckit.probe.taskstoissueswith aliasspeckit.taskstoissues(a live core command).git checkout HEAD~1 -- src/specify_cli/extensions/__init__.py), confirmed the new test fails (Failed: DID NOT RAISE ValidationError), restored the fix, confirmed it passes.tests/test_extensions.py: 536 passed.python -m pytest tests -q): 8054 passed, 12 skipped, no failures.AI Disclosure
This fix was implemented with Claude Code (Claude Sonnet 5), based on the reproduction and root-cause analysis in the linked issue. I reviewed the code paths involved (
_collect_manifest_command_names,_get_installed_command_name_map,_validate_install_conflicts), confirmed the fail-before/pass-after test behavior described above, and ran the full test suite myself before opening this PR.🤖 Generated with Claude Code