Repository navigation
Commit 28de2b2
committed
fix: Name the over-long binding in the let identifier error
Review finding on #348. The validator is a `field_validator` on the whole
`let` list, so pydantic anchors the error at `steps[0] -> let` with no list
index. Measured on a four-binding template where the third name is 513
characters: the error was
steps[0] -> let:
A 'let' binding name must be at most 512 characters long
which identifies neither the binding nor its position. With 50 bindings
allowed that is not diagnosable.
Truncate rather than omit, as the reviewer suggested. The message now
carries a 32-character prefix and the true length:
A 'let' binding name must be at most 512 characters long:
'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'... (513 characters)
Total error text goes from 110 to 166 characters, so it stays bounded while
becoming locatable. The original concern about a 513-character name dwarfing
the diagnostic still holds against interpolating the name in full, which is
why this truncates.
Two assertions pin it, both mutation-checked: reverting to the bare message
fails `test_name_513_chars` and the new
`test_name_513_chars_names_the_offending_binding`, which uses a
multi-binding `let` to cover the case the finding was about.
No matching change in openjd-rs: its path is `steps[0] -> let[0]`, so the
index already identifies the binding there.
Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>1 parent e06517a commit 28de2b2
2 files changed
Lines changed: 16 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
946 | 946 | | |
947 | 947 | | |
948 | 948 | | |
949 | | - | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
950 | 952 | | |
951 | 953 | | |
952 | | - | |
| 954 | + | |
| 955 | + | |
953 | 956 | | |
954 | 957 | | |
955 | 958 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
125 | 128 | | |
126 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
127 | 137 | | |
128 | 138 | | |
129 | 139 | | |
| |||
0 commit comments