Repository navigation
Commit 262d3d2
authored
fix: Enforce the 512-character cap on a let binding identifier (#348)
* fix: Enforce the 512-character cap on a let binding identifier
Template Schemas §3.6.1 caps a `<UserIdentifier>` at 512 characters. Nothing
checked it, so a 513-character `let` binding name was accepted. The
conformance fixture pinning this is
`EXPR/job_templates/proposed/3.6.1--let-identifier-513.invalid.yaml`, added
by openjd-specifications#164, which failed here and in openjd-rs alike.
The cap is a flat 512 and deliberately does not reuse the §7.1
`<Identifier>` cap that `NameIdentifierLengthMixin` and the inline
`512 if "FEATURE_BUNDLE_1" in context.extensions else 64` checks apply.
§3.6.1 states one maximum for a `<UserIdentifier>` and gates it on no
extension, and the fixture pair proves the flat reading: the 512-character
accept twin `EXPR/job_templates/3.6--let-boundary-edges.yaml` declares EXPR
alone, so borrowing the §7.1 cap would limit it to 64 and reject a template
the spec permits. The two caps share the number 512 and nothing else, so
this adds `LET_MAX_IDENTIFIER_LEN` beside the existing `LET_MAX_BINDINGS`
with its own citation. EXPR gates whether `let` exists at all and moves
neither cap.
All four `_validate_let` field validators route through
`validate_let_field` and then `parse_let_bindings`, so the check goes in
`parse_let_bindings` after the `_LET_NAME_RE` match and every scope is
covered by one insertion. The message omits the offending name: at 513
characters it would dwarf the diagnostic.
Six tests, mutation-checked: removing the check fails all three reject tests
while the three accept tests keep passing, so the accept cases act as
negative controls against a cap set too low. The default `_job` helper
declares EXPR alone, which is what would catch a regression to the
FEATURE_BUNDLE_1-gated cap; the `_with_fb1` variants pin that declaring
FEATURE_BUNDLE_1 does not move it.
The matching openjd-rs change is OpenJobDescription/openjd-rs#358.
Design note: SuperDaveDocs docs/conformance-0901/4.6-let-513/fix.md
Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
* chore: Shorten the let identifier cap comments
The rationale lives in the commit message, the PR description and the
design note. The code only needs the citation and the one fact a reader
editing this line must not miss: the cap is flat, so it is not the
FEATURE_BUNDLE_1-gated section 7.1 cap.
Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
* 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>
* test: Reference the bound name in the let length accept cases
Review finding on #348. The three accept-side tests bound a 512-character
name and never referenced it, so they proved `parse_let_bindings` does not
raise but not that the binding is usable, which is the property the
conformance fixture is about.
Each now interpolates the bound name in the script args, so the name flows
through the variable-reference validation and into the expression parser. All
24 tests still pass, which answers the finding's concern directly: no cap
further down that path, in `Identifier`, `FormatString`, or the Rust
expression layer, rejects a 512-character binding.
Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
---------
Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>1 parent 085609a commit 262d3d2
2 files changed
Lines changed: 70 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
921 | 921 | | |
922 | 922 | | |
923 | 923 | | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
924 | 929 | | |
925 | 930 | | |
926 | 931 | | |
| |||
941 | 946 | | |
942 | 947 | | |
943 | 948 | | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
944 | 957 | | |
945 | 958 | | |
946 | 959 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
44 | 67 | | |
45 | 68 | | |
46 | 69 | | |
| |||
98 | 121 | | |
99 | 122 | | |
100 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
101 | 158 | | |
102 | 159 | | |
103 | 160 | | |
| |||
0 commit comments