Commit 725d61d
authored
fix(extractors): guard empty-text identifiers and isolate extractor crashes (#972)
* fix(extractors): guard empty-text identifiers and isolate extractor crashes
The JavaScript extractor's factory-call type-map path called
`objName[0]!.toLowerCase()` without guarding for empty strings. When
tree-sitter produces a partial or corrupted tree the identifier's `text`
can be `''`, which makes `objName[0]` undefined and crashes with
"Cannot read properties of undefined (reading 'toLowerCase')". The
Python extractor already uses the correct short-circuit pattern; mirror
it in JS.
Additionally wrap the WASM extractor invocation in `wasmExtractSymbols`
in a try/catch that logs via `warn()` and returns `null`, mirroring the
existing parse-error handling directly above. Previously any extractor
runtime error would bubble up and kill the whole graph build; now the
build continues past the broken file.
Includes a regression test exercising a mock tree with an
empty-text identifier to verify the guard no longer throws.
Fixes #964
Impact: 2 functions changed, 16 affected
* fix(parser): free WASM tree on extractor error path (#972)
Addresses Greptile review feedback: when entry.extractor() throws, the
tree object allocated by parser.parse was never deleted. Since
web-tree-sitter trees are backed by WASM linear memory and not
garbage-collected, each extractor crash leaked one tree for the process
lifetime. Matches the finally/delete pattern already used in
backfillTypeMap and backfillTypeMapBatch.
Impact: 1 functions changed, 12 affected1 parent 0ecd0fc commit 725d61d
3 files changed
Lines changed: 88 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
786 | 786 | | |
787 | 787 | | |
788 | 788 | | |
789 | | - | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
790 | 799 | | |
791 | 800 | | |
792 | 801 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1182 | 1182 | | |
1183 | 1183 | | |
1184 | 1184 | | |
1185 | | - | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
1186 | 1190 | | |
1187 | 1191 | | |
1188 | 1192 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
187 | 260 | | |
188 | 261 | | |
189 | 262 | | |
| |||
0 commit comments