Repository navigation
Commit 6a29c59
authored
feat(pyamber): reject non-string state keys (#8959)
### What changes were proposed in this PR?
Reject non-string state dictionary keys before serialization. Converting
both 1 and "1" to the same JSON key silently loses a value. This
introduces an explicit TypeError for non-string keys, including nested
mappings.
### Any related issues, documentation, discussions?
Closes #8215
Replaces #8216, which the stale bot closed. The original PR cannot be
reopened by this account.
### How was this PR tested?
Tested on freshly fetched main at
d27b7b4 with Python 3.12 on Windows.
The regression failed before the source change and passed after it.
From the amber directory, with generated protobuf bindings available on
PYTHONPATH:
```text
python -m pytest src/test/python/core/models/test_state.py::TestState::test_to_json_rejects_non_string_keys -q --tb=line -p no:cacheprovider
python -m pytest src/test/python/core/models src/test/python/core/architecture/sendsemantics/test_partitioners.py --deselect src/test/python/core/models/test_tuple.py::TestTuple::test_hash -q --tb=line -p no:cacheprovider
ruff check src/main/python src/test/python
ruff format --check src/main/python src/test/python
```
The broader suites passed 351 tests with one expected failure. Ruff lint
and formatting passed for all 216 Python files. The existing Windows
pre-epoch hash fixture was deselected; the new hash regressions were run
separately.
### Was this PR authored or co-authored using generative AI tooling?
Generated-by: Codex (GPT-6)1 parent 9cf43f2 commit 6a29c59
2 files changed
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
97 | 99 | | |
98 | 100 | | |
99 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
93 | 100 | | |
94 | 101 | | |
95 | 102 | | |
| |||
0 commit comments