fix(package): leave actions.yaml untouched if it exists in stage
Metadata
Current evaluation
Fixes actions.yaml being incorrectly unlinked during packaging when staged from non-reactive charms. Adds a stage directory existence check. Clean diff, CI passing, awaiting review.
Suggested action: needs review
Reason: The PR makes a targeted +20/-0 line fix to prevent actions.yaml from being unlinked during packaging when it exists in the stage directory but isn't from a reactive charm. The diff is clean, CI is passing (OSV-scanner failure is an unrelated security scan), and a unit test is included. It has 0 reviewers and 0 comments after 3 days, so it needs maintainer review.
Evaluated by: mr-cal-bot
Impact:
55
Quick Win:
37
Complexity:
15
Confidence:
80
Actionability:
80
Issue body
When `actions.yaml` is staged during the build lifecycle (for example, in charms containing legacy or unenforced `actions.yaml` files staged from the project tree, or reactive charms generating actions), `PackageService.get_actions_yaml` now returns `False` so that craft-application's package file mediation leaves the staged and primed file untouched instead of unlinking it.
### Root cause
In #2890, mediated packaging was introduced. When `actions.yaml` contained non-conforming syntax (e.g. in `tests/spread/smoketests/metafiles-bad-yaml-unenforced`), `preprocess.add_actions` did not populate `yaml_data['actions']`, leaving `project.actions` as `None`. `_get_mediated_yaml` therefore returned `None`, causing `_write_asset` to unlink `actions.yaml` from the prime directory.
### Solution
Check if `actions.yaml` exists in the stage directory in `PackageService.get_actions_yaml()`. If present, emit debug and return `False`, leaving the file untouched in `prime`.
### Verification
- Added unit test `test_get_actions_yaml_skips_when_exists_in_stage` in `tests/unit/services/test_package.py`.
- Ran `make test-fast` (2849 passed).
- Ran `ruff check`, `ruff format --diff`, and `ty check` (all passed).
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b |
Impact:
55
Quick Win:
37
Complexity:
15
Confidence:
80
Actionability:
80
|
needs review | Fixes actions.yaml being incorrectly unlinked during packaging when staged from non-reactive charms. Adds a stage directory existence check. Clean diff, CI passing, awaiting review. |
Update history
| Date | Change |
|---|---|
| created |
Related issues
No related issues found above the similarity threshold.