Commit fd33d24
committed
fix(sdk): reject scalar str/bytes for get_many ids and attributes
`{"InfraDevice": {"ids": "dev-1"}}` and
`{"InfraDevice": {"ids": ["dev-1"], "attributes": "name"}}` are easy
mistakes — a caller with one id or one attribute reaches for the bare
value rather than wrapping it in a list. Strings and bytes are
iterable in Python, so the compiler used to walk them
character-by-character: the first form sent seven one-character
GraphQL ids, and the second built a selection set of
`n { value } a { value } m { value } e { value }` because each
character passed the GraphQL-identifier regex.
Reject `str`/`bytes` explicitly for both fields and surface a
descriptive `ValidationError` instead. The original list-of-id /
list-of-attribute path is unchanged.
Reported by the cubic AI code reviewer on #1108.1 parent e52ccca commit fd33d24
2 files changed
Lines changed: 34 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
206 | | - | |
207 | | - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
208 | 211 | | |
209 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
210 | 218 | | |
211 | 219 | | |
212 | 220 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 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 | + | |
124 | 148 | | |
125 | 149 | | |
126 | 150 | | |
| |||
0 commit comments