Fix targets:/skills:/alias: ignored on path: dependency entries#1987
Open
sergio-sisternes-epam wants to merge 2 commits into
Open
Fix targets:/skills:/alias: ignored on path: dependency entries#1987sergio-sisternes-epam wants to merge 2 commits into
sergio-sisternes-epam wants to merge 2 commits into
Conversation
parse_from_dict early-returned after cls.parse(local) for local path
deps, silently discarding any targets:, skills:, or alias: fields from
the entry dict. git: deps were unaffected because their optional-field
extraction block runs after the initial cls.parse() call.
Fix 1 -- parse_from_dict: stop early-returning for path: entries
Replace the bare return cls.parse(local) with dep = cls.parse(local),
then read and apply alias, skills, and targets from the entry dict
before returning dep. Validation mirrors the git: path exactly.
Fix 2 -- to_apm_yml_entry: emit {path: ...} for local deps with subsets
The existing if self.skill_subset or self.target_subset: branch emitted
{git: ...} unconditionally, which would re-parse a local dep as a remote
git URL on the next load. Add an early-exit guard for is_local deps that
emits the correct {path: ...} key with alias/skills/targets.
No pipeline changes needed -- install/template.py already reads
dep_ref.target_subset and passes it to integrate_package_primitives.
The bug was entirely in model parsing.
Fixes #1982
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a model-layer parsing/serialization bug where object-form local path: dependencies dropped targets:, skills:, and alias: during apm install, and ensures to_apm_yml_entry() round-trips local deps correctly.
Changes:
- Preserve and validate
alias:,skills:, andtargets:for object-formpath:dependencies inDependencyReference.parse_from_dict. - Serialize local
path:dependencies as{path: ...}dict entries (with optionalalias/skills/targets) instead of incorrectly emitting{git: ...}when subsets are present. - Add unit tests covering
targets:/skills:persistence for localpath:deps and documenttargets:support forpath:dependencies.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/apm_cli/models/dependency/reference.py | Fix parsing and serialization so local path: deps honor alias/skills/targets and serialize symmetrically. |
| tests/unit/test_dep_targets_persistence.py | Add regression coverage for targets: on local path: deps. |
| tests/unit/test_skill_subset_persistence.py | Add regression coverage for skills: on local path: deps and dict-form emission. |
| packages/apm-guide/.apm/skills/apm-usage/dependencies.md | Document that targets: applies to both git: and path: dependency forms. |
- to_apm_yml_entry docstring now documents the local-path dict serialization case (path + alias/skills/targets) alongside the existing HTTP and git-with-subsets cases. - Add three TestLocalPathDepTargets tests covering path: + alias: parsing, round-trip serialization, and invalid-alias rejection. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
TL;DR
targets:,skills:, andalias:on apath:dependency entry were silently ignored duringapm install. This PR fixes the two-line root cause and adds serialization symmetry plus full test coverage.Fixes #1982
Problem (WHY)
DependencyReference.parse_from_dicthandledpath:entries with an earlyreturn cls.parse(local)that discarded every other field in the entry dict:For
git:entries the same method readstargets_raw = entry.get("targets")and applies it. Localpath:entries fell off the bottom of that block entirely.Secondary:
to_apm_yml_entryalways emitted{"git": ...}whenskill_subsetortarget_subsetwas set -- correct for remote deps, wrong for local ones (would round-trip as a remote git URL).Approach (WHAT)
return cls.parse(local)withdep = cls.parse(local), then read and applyalias,skills, andtargetsfrom the entry dict before returning. Validation mirrors thegit:path exactly.is_localdeps that emits{"path": ...}with the correct optional keys instead of falling into the{"git": ...}block.Implementation (HOW)
Files changed
src/apm_cli/models/dependency/reference.pyparse_from_dict+to_apm_yml_entrytests/unit/test_dep_targets_persistence.pyTestLocalPathDepTargets-- 5 new teststests/unit/test_skill_subset_persistence.pypath:+skills:testspackages/apm-guide/.apm/skills/apm-usage/dependencies.mdpath:support fortargets:Trade-offs
install/template.pyalready threadsdep_ref.target_subsetintointegrate_package_primitives. The bug was entirely in the model layer.path:branch ofparse_from_dictand an early-exit guard into_apm_yml_entrychange. Allgit:behaviour is unchanged.Validation evidence
How to test