← Back to issue list

`CraftSpreadYaml` should accept the `environment` key

View original Github issue

Metadata

Project
craft-application
Number
#923
Type
issue
State
open
Author
lczyk
Labels
Type: Enhancement Status: Needs information
Created
Updated
Closed

Current evaluation

Request to add top-level environment key to CraftSpreadYaml/CraftTestYaml for global spread test env vars. Triaged, maintainer says implementation is trivial but decision pending. Author found per-suite workaround; feature still unimplemented.

Suggested action: keep open

Reason: Maintainer @lengau acknowledged the issue and explicitly stated 'Implementation is trivial — deciding whether this is something we want to include is nontrivial!' while tagging @cmatsuoka for a decision. The author found a per-suite workaround but noted 'the global environment would still be nice.' The code still lacks the feature (CraftTestYaml has extra='forbid' with no environment field), and the issue remains valid despite 339 days of inactivity.

Impact: 35 Quick Win: 24.5 Staleness: 55 Complexity: 30 Confidence: 72 Support Request: 10

Issue body

### What needs to get done `CraftSpreadYaml` model at `craft_application/models/spread.py` does not accept the `environment` key which limits the ways in which the spread test can be set up. ## specific example in [`chisel-releases`](https://github.com/canonical/chisel-releases/) we use the [`environment`](https://github.com/canonical/chisel-releases/) key to add [an entry](https://github.com/canonical/chisel-releases/tree/ubuntu-25.10/tests/spread/lib) to the PATH with extra libraries. there we run the tests with `spread` directly, and all is great. i've been working on the [`rust-rock`](https://github.com/canonical/rust-rock) recently, and i wanted to implement this kind of pattern (which would eventually hopefully be adopted by into the [`rocks-template`](https://github.com/canonical/rust-rock)), however, when [trying it out](https://github.com/canonical/rust-rock/blob/2308e92ca6ea860c4e4f4c9a83afe1b6e509257d/rust-rock/1.84-25.04/spread.yaml#L10), the test [fails in the cli](https://github.com/canonical/rust-rock/actions/runs/18040922328/job/51339387123?pr=3#step:5:2882) (relevant logs pasted below in case the cli logs are no longer available). i've tracked the issue down to the fact that the builder [calls `rockcraft test`](https://github.com/canonical/craft-actions/blob/6376f70bf549a27bf96786aa6e7e17b5d43c0ff1/src/rockcraft-pack.ts#L65-L66) rather than using `spread` (called by the [`oci-factory`](https://github.com/canonical/oci-factory/blob/a24ea920d8bacfb43c2616672859b491a78d3258/.github/workflows/Build-Rock.yaml#L138-L139)). from there + actually looking at the python stacktrace, i've narrowed it down to [`CraftSpreadYaml`](https://github.com/canonical/craft-application/blob/89382915f754729c6336f6e7b060739033c0ded8/craft_application/models/spread.py#L74-L75) being self-proclaimedly only a simplified version. ``` 2025-09-26 14:43:15.904 rockcraft internal error: 1 validation error for CraftSpreadYaml 2025-09-26 14:43:15.904 environment 2025-09-26 14:43:15.904 Extra inputs are not permitted [type=extra_forbidden, input_value={'SHARED_LIBRARIES': '$PR...PATH:$SHARED_LIBRARIES'}, input_type=dict] 2025-09-26 14:43:15.904 For further information visit https://errors.pydantic.dev/2.11/v/extra_forbidden 2025-09-26 14:43:15.911 Traceback (most recent call last): 2025-09-26 14:43:15.912 File "/snap/rockcraft/3592/lib/python3.12/site-packages/craft_application/application.py", line 650, in run 2025-09-26 14:43:15.912 return_code = self._run_inner() 2025-09-26 14:43:15.912 ^^^^^^^^^^^^^^^^^ 2025-09-26 14:43:15.912 File "/snap/rockcraft/3592/lib/python3.12/site-packages/craft_application/application.py", line 627, in _run_inner 2025-09-26 14:43:15.912 return_code = dispatcher.run() or os.EX_OK 2025-09-26 14:43:15.912 ^^^^^^^^^^^^^^^^ 2025-09-26 14:43:15.912 File "/snap/rockcraft/3592/lib/python3.12/site-packages/craft_cli/dispatcher.py", line 564, in run 2025-09-26 14:43:15.912 return self._loaded_command.run(self._parsed_command_args) 2025-09-26 14:43:15.912 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-09-26 14:43:15.912 File "/snap/rockcraft/3592/lib/python3.12/site-packages/craft_application/commands/base.py", line 200, in run 2025-09-26 14:43:15.912 result = self._run(parsed_args, **kwargs) or result 2025-09-26 14:43:15.912 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-09-26 14:43:15.912 File "/snap/rockcraft/3592/lib/python3.12/site-packages/craft_application/commands/lifecycle.py", line 684, in _run 2025-09-26 14:43:15.912 testing_service.test( 2025-09-26 14:43:15.912 File "/snap/rockcraft/3592/lib/python3.12/site-packages/craft_application/services/testing.py", line 69, in test 2025-09-26 14:43:15.912 self.process_spread_yaml(temp_spread_file, pack_state) 2025-09-26 14:43:15.912 File "/snap/rockcraft/3592/lib/python3.12/site-packages/craft_application/services/testing.py", line 108, in process_spread_yaml 2025-09-26 14:43:15.912 simple = models.CraftSpreadYaml.unmarshal(data) 2025-09-26 14:43:15.912 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-09-26 14:43:15.912 File "/snap/rockcraft/3592/lib/python3.12/site-packages/craft_application/models/base.py", line 64, in unmarshal 2025-09-26 14:43:15.913 return cls.model_validate(data) 2025-09-26 14:43:15.913 ^^^^^^^^^^^^^^^^^^^^^^^^ 2025-09-26 14:43:15.913 File "/snap/rockcraft/3592/lib/python3.12/site-packages/pydantic/main.py", line 705, in model_validate 2025-09-26 14:43:15.913 return cls.__pydantic_validator__.validate_python( 2025-09-26 14:43:15.913 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-09-26 14:43:15.913 pydantic_core._pydantic_core.ValidationError: 1 validation error for CraftSpreadYaml 2025-09-26 14:43:15.913 environment 2025-09-26 14:43:15.913 Extra inputs are not permitted [type=extra_forbidden, input_value={'SHARED_LIBRARIES': '$PR...PATH:$SHARED_LIBRARIES'}, input_type=dict] 2025-09-26 14:43:15.913 For further information visit https://errors.pydantic.dev/2.11/v/extra_forbidden 2025-09-26 14:43:15.913 Full execution log: '/home/ubuntu/.local/state/rockcraft/log/rockcraft-20250926-144007.309280.log' ``` ### Why it needs to get done it would be really great if this functionality would be added so we can bump the `craft_application` version in `rockcraft` and configure our tests better. hope it's not tricky and that i've diagnosed the issue correctly.

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 35
Quick Win: 24.5
Staleness: 55
Complexity: 30
Confidence: 72
Support Request: 10
keep open Request to add top-level environment key to CraftSpreadYaml/CraftTestYaml for global spread test env vars. Triaged, maintainer says implementation is trivial but decision pending. Author found per-suite workaround; feature still unimplemented.
qwen/qwen3.8-27b
Impact: 25
Quick Win: 17.5
Staleness: 70
Complexity: 30
Confidence: 80
Support Request: 10
keep open Enhancement request to add top-level `environment` key support to CraftSpreadYaml/CraftTestYaml for spread test configuration. Triaged and labelled; author found a per-suite workaround and noted it is less pressing. Feature still not implemented in current code.
qwen/qwen3.8-27b
Impact: 35
Quick Win: 22.75
Staleness: 65
Complexity: 35
Confidence: 80
Support Request: 10
keep open Request to allow the top-level 'environment' key in the craft test spread.yaml model (CraftSpreadYaml), which forbids it. Triaged as enhancement; reporter found per-suite environment works as a workaround. Still unfixed in current code.
qwen/qwen3.6-35b-a3b
Staleness: 80
Complexity: 10
Confidence: 60
Support Request: 0
needs triage Enhancement request to add environment key support to CraftSpreadYaml model. Awaiting architectural decision from maintainers; author notes a workaround exists but feature remains desirable.
qwen3.6-35b-a3b-mtp-q6
Staleness: 75
Complexity: 15
Confidence: 70
Support Request: 0
needs triage Enhancement request to add environment key support to CraftSpreadYaml model. Author found a workaround, reducing urgency. Awaiting maintainer design decision on whether to implement.
qwen3.6-35b-a3b-mtp-q6
Staleness: 80
Complexity: 20
Confidence: 75
Support Request: 0
close stale CraftSpreadYaml rejects the environment key, blocking spread test setup. Maintainers are discussing whether to add it, noting implementation is trivial but the decision requires review. Workaround available. Status: needs information.

Update history

No update history recorded yet.

Related work

  • Related To: craft-application#1168 (confidence 85%)

    PR #1168 deprecated CraftSpreadYaml in favor of <app-name>-test.yaml (CraftTestYaml), which has the same extra='forbid' limitation and also lacks a top-level environment field.

Related issues

No related issues found above the similarity threshold.