← Back to issue list

Unexpected behavior for multiple `to` statements

View original Github issue

Metadata

Project
craft-grammar
Number
#89
Type
issue
State
open
Author
mr-cal
Labels
Created
Updated
Closed

Current evaluation

craft-grammar silently mishandles multiple `to` statements combined with `else`: armhf build yields [foo, baz] while riscv64 yields [bar], with no error or warning. Maintainer comment (2025-06-11) suggests supporting multiple `to` directives since `to` matches on AND criteria. No fix found in code or history; issue open, unlabelled.

Suggested action: keep open

Reason: A maintainer (simondeziel) engaged on 2025-06-11 proposing to support multiple `to` directives, and the internal ticket CRAFT-4486 was created, so the issue is triaged and acknowledged. The current code in _processor.py still finalizes each `to` statement independently and attaches `else` only to the last active statement, confirming the reported behavior persists. The fix requires a design decision (error vs. proper multi-`to` handling) affecting grammar semantics, so it should remain open.

Impact: 50 Quick Win: 17.5 Staleness: 55 Complexity: 65 Confidence: 70 Support Request: 5

Issue body

Given the following: ```yaml parts: my-part: build-packages: - to armhf: - foo - to riscv64: - bar - else: - baz ``` Building for armhf will evaluate to `["foo", "baz"]` and building for riscv64 will evaluate to `["bar"]`. This is an unexpected UX and there are no warnings or errors to explain the behavior. Either craft-grammar should error when given multiple `to` statements with an `else` or it should properly handle this scenario. A reproducer in the unit test suite can be seen here: https://github.com/canonical/craft-grammar/commit/12c031a207eaec4e1c345ad8a9ad2444ec4429ae Source: https://github.com/canonical/snapcraft/issues/5255

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 50
Quick Win: 17.5
Staleness: 55
Complexity: 65
Confidence: 70
Support Request: 5
keep open craft-grammar silently mishandles multiple `to` statements combined with `else`: armhf build yields [foo, baz] while riscv64 yields [bar], with no error or warning. Maintainer comment (2025-06-11) suggests supporting multiple `to` directives since `to` matches on AND criteria. No fix found in code or history; issue open, unlabelled.
qwen/qwen3.6-35b-a3b
Staleness: 90
Complexity: 65
Confidence: 80
Support Request: 10
keep open Grammar parser produces unexpected results with multiple to statements and else. Inactive for over a year, lacks labels, but has maintainer input.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 55
Confidence: 70
Support Request: 15
needs triage Unexpected behavior when using multiple to statements with an else clause in craft-grammar YAML. Currently evaluates incorrectly without warnings. Awaiting triage and resolution.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 55
Confidence: 75
Support Request: 10
needs triage craft-grammar mishandles multiple to statements with an else fallback, yielding unexpected package lists without warnings. Open issue linked to CRAFT-4486. Developers propose supporting multiple to directives instead of erroring, pending resolution.

Update history

No update history recorded yet.

Related issues

No related issues found above the similarity threshold.