← Back to issue list

Regression: Advanced grammar cannot be combined with other data

View original Github issue

Metadata

Project
snapcraft
Number
#4764
Type
issue
State
closed
Author
mr-cal
Labels
—
Created
Updated
Closed

Current evaluation

Fixed by merged snapcraft#4768 (c76e62671), adding regression coverage for mixed grammar and standard list entries; parsing was fixed in craft-application 2.6.2.

Resolution: closed resolved

Reason: Maintainer mr-cal closed the report after #4768 merged as commit c76e62671. The PR added spread tests for lists combining grammar and non-grammar entries, using the parser fix delivered by craft-application 2.6.2.

Evaluated by: mr-cal-bot

No scores available.

Issue body

### Bug Description @kubiko raised a bug ([LP#2061603](https://bugs.launchpad.net/snapcraft/+bug/2061603)) where grammar was applied before root-level keywords were applied to parts. #4753 recently fixed this regression, but there is still another regression where grammar cannot be combined with other data. For example, Snapcraft can parse: ```yaml build-packages: - on amd64: - gcc-aarch64-linux-gnu ``` But Snapcraft cannot parse: ```yaml build-packages: - build-essential - on amd64: - gcc-aarch64-linux-gnu ``` ### To Reproduce snapcraft pack ### Environment n/a ### snapcraft.yaml ```shell name: test-snap version: '0.1' summary: test description: test grade: devel confinement: devmode base: core24 platforms: amd64: parts: my-part: plugin: nil build-packages: - build-essential - on amd64: - gcc-aarch64-linux-gnu - on arm64: - gcc ``` ### Relevant log output ```shell 2024-04-29 07:28:16.113 Starting snapcraft, version 8.2.1 2024-04-29 07:28:16.113 Log verbosity level set to BRIEF 2024-04-29 07:28:16.115 Configuring application... 2024-04-29 07:28:16.115 Preparing application... 2024-04-29 07:28:16.116 Build plan: platform=None, build_for=None 2024-04-29 07:28:16.116 Loading project file '/tmp/foo/snapcraft.yaml' 2024-04-29 07:28:16.117 Setting target machine to x86_64 2024-04-29 07:28:16.122 Processing grammar (on amd64 for amd64) 2024-04-29 07:28:16.122 Processing grammar for plugin: nil 2024-04-29 07:28:16.122 Processing grammar for build-packages: ['build-essential', {'on amd64': ['gcc-aarch64-linux-gnu']}, {'on arm64': ['gcc']}] 2024-04-29 07:28:16.123 Bad snapcraft.yaml content: - string type expected (in field 'parts.my-part.build-packages[1]') - string type expected (in field 'parts.my-part.build-packages[2]') 2024-04-29 07:28:16.124 Traceback (most recent call last): 2024-04-29 07:28:16.124 File "/snap/snapcraft/11471/lib/python3.10/site-packages/snapcraft/models/project.py", line 826, in unmarshal 2024-04-29 07:28:16.124 project = Project(**data) 2024-04-29 07:28:16.124 File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__ 2024-04-29 07:28:16.124 pydantic.error_wrappers.ValidationError: 2 validation errors for Project 2024-04-29 07:28:16.124 parts -> my-part -> build-packages -> 1 2024-04-29 07:28:16.124 str type expected (type=type_error.str) 2024-04-29 07:28:16.124 parts -> my-part -> build-packages -> 2 2024-04-29 07:28:16.124 str type expected (type=type_error.str) 2024-04-29 07:28:16.124 Full execution log: '/home/developer/.local/state/snapcraft/log/snapcraft-20240429-072816.112973.log' ``` ### Additional context _No response_

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Fixed by merged snapcraft#4768 (c76e62671), adding regression coverage for mixed grammar and standard list entries; parsing was fixed in craft-application 2.6.2.
stealth/space-bunny-alpha — closed resolved Fixed by merged PR #4768 (c76e6267), adding regression coverage for mixed grammar and standard list entries; craft-application 2.6.2 supplied the underlying parsing fixes.
qwen/qwen3.6-35b-a3b — — Fixed a regression preventing advanced grammar from combining with other data in Snapcraft YAML. Resolved via pull request #4768, which updated parsing logic to correctly handle mixed grammar and standard entries.
qwen/qwen3.6-35b-a3b — — Fixed a regression where advanced grammar syntax could not be combined with other list data in snapcraft.yaml. Resolved and merged via pull request #4768.
qwen/qwen3.6-35b-a3b — — Fixed a regression preventing advanced grammar from combining with other data in build-packages. Resolved and closed via pull request #4768.
qwen3.6-35b-a3b-mtp-q6 — — Fixed a regression where advanced grammar syntax could not combine with other data in lists. Resolved by merging pull request #4768, allowing conditional and unconditional entries to coexist in configuration fields.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: snapcraft#4768 (confidence 100%)

    Merged regression-test PR that closed the issue, commit c76e62671.

  • Likely Fixed By: craft-application#330 (confidence 95%)

    Underlying parser change included in craft-application 2.6.2.

  • Related To: snapcraft#4753 (confidence 95%)

    Earlier partial fix for advanced grammar in root-level keywords.

Related issues

Issue Project State Summary Similarity
#328 fix: allow a mix of strings and dicts for grammar craft-application merged Merged craft-application#328 as commit 2a1115d0, allowing grammar lists to mix strings and dicts; released in 2.6.2 and regression-tested by snapcraft#4768.
77%
#1684 Vendor grammar logic into snapcraft snapcraft closed Advanced grammar was extracted to craft-grammar and adopted by Snapcraft in #3642 (merge 943d130c2), superseding the planned in-tree refactor.
72%
#4768 tests(spread): regression test for grammar and non-grammar lists snapcraft merged Merged PR #4768 (c76e62671) added spread regressions for mixed grammar/non-grammar lists and fixed #4764 through craft-application 2.6.2 parser fixes.
72%