craft-grammar does not coerce numbers to strings in annotated types
Metadata
Current evaluation
Fixed numeric-to-string coercion for annotated types by merging canonical/craft-grammar#50 in commit 3c244fa; the ineffective, unmerged PR #46 was superseded.
Resolution: closed resolved
Reason: Resolved by merged PR canonical/craft-grammar#50, commit 3c244fa, which restored numeric-to-string coercion in models, including annotated fields. PR #46 was closed unmerged after its coercion approach proved ineffective.
Evaluated by: mr-cal-bot
No scores available.
Issue body
Pydantic 2 requires `coerce_numbers_to_str = True` to be set, but this does not work for annotated types, such as craft-application's `SingleEntryDict`:
```python
SingleEntryDict = Annotated[
dict[T, Tv],
pydantic.Field(min_length=1, max_length=1),
]
```
Parsing the following with craft-grammar
```yaml
build-environment:
- CGO_ENABLED: 0
```
produces
```
> v = ValidationTest(**data)
E pydantic_core._pydantic_core.ValidationError: 1 validation error for ValidationTest
E build_environment
E Value error, value must be a list of Annotated: [{'CGO_ENABLED': 0}] [type=value_error, input_value=[{'CGO_ENABLED': 0}], input_type=list]
E For further information visit https://errors.pydantic.dev/2.9/v/value_error
```
See full logs in this PR: https://github.com/canonical/craft-grammar/pull/46
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Fixed numeric-to-string coercion for annotated types by merging canonical/craft-grammar#50 in commit 3c244fa; the ineffective, unmerged PR #46 was superseded. | |
| stealth/space-bunny-alpha | — | closed superseded | Annotated types failed to coerce numeric values to strings despite coerce_numbers_to_str. The initial fix in PR #46 was superseded by PR #50, merged as commit 3c244fa. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without resolution. Synced to internal Jira ticket CRAFT-3389. No fix or merge activity was recorded, indicating the issue was likely abandoned or deferred. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without resolution. The issue was deferred to internal tracking via Jira ticket CRAFT-3389 after reporting that Pydantic 2's coerce_numbers_to_str setting fails for annotated types in craft-grammar. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed after an internal Jira ticket was created to track the Pydantic 2 annotation coercion bug. No code fix or merge was applied. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without resolution. The report details Pydantic 2 coercion failures for annotated types in craft-grammar. Synced to Jira but never fixed or merged. |
Update history
No update history recorded yet.
Related work
-
Likely Fixed By:
canonical/craft-grammar#50
(confidence 100%)
Merged fix for model numeric-to-string coercion.
-
Related To:
canonical/craft-grammar#46
(confidence 99%)
Earlier coercion fix was closed unmerged and superseded by PR #50.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #46 fix: coerce numbers to strings | craft-grammar | closed | Closed unmerged as ineffective; merged PR canonical/craft-grammar#50 restored numeric-to-string coercion in commit 3c244fa. |