Skip to content

fix(package): leave actions.yaml untouched if it exists in stage - #2977

Draft
LoweRAM wants to merge 1 commit into
canonical:mainfrom
LoweRAM:fix/skip-actions-yaml-if-staged
Draft

LoweRAM wants to merge 1 commit into
canonical:mainfrom
LoweRAM:fix/skip-actions-yaml-if-staged

Conversation

@LoweRAM

@LoweRAM LoweRAM commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

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).

When actions.yaml is generated or staged during the lifecycle, return False from get_actions_yaml() so that mediated packaging does not overwrite or unlink it in the prime directory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant