Currently, the only error we can raise in case of syntax errors is "Invalid query", which is not helpful for users.
We should find a way to turn tree-sitter's partial ASTs into proper errors, so users know what to fix in their query.
Currently, the only error we can raise in case of syntax errors is "Invalid query", which is not helpful for users.
We should find a way to turn tree-sitter's partial ASTs into proper errors, so users know what to fix in their query.
Status | Assigned | Task | ||
---|---|---|---|---|
Migrated | gitlab-migration | T3097 Expose metadata in the WebApp and make it searchable | ||
Migrated | gitlab-migration | T3952 Make the search query language a first class citizen | ||
Migrated | gitlab-migration | T3558 Enable the swh-search QL in production | ||
Migrated | gitlab-migration | T3559 Enable the swh-search QL in staging | ||
Migrated | gitlab-migration | T3967 "Link" header is not properly displayed in apidoc when it contains [] | ||
Migrated | gitlab-migration | T3560 Polish the swh-search QL | ||
Migrated | gitlab-migration | T3926 Better syntax errors for the search query language | ||
Restricted Maniphest Task | ||||
Migrated | gitlab-migration | T3944 Deploy swh-search v0.13.0 | ||
Migrated | gitlab-migration | T3943 rebuild python3-tree-sitter for python 3.10 |
Possible invalid queries [WIP]:
Query: origin in 23
sexp: (ERROR (patternField) (choiceOp) (number))
root.type: ERROR
root.has_error: True
The root node's children are normal in this case.
Query: poke = mon
sexp: (ERROR (UNEXPECTED 'o') (rangeOp) (UNEXPECTED 'n'))
root.children: [<Node type=ERROR>, <Node type=rangeOp>, <Node type=ERROR>]
The type=ERROR nodes don't have any children. So <Node type=UNEXPECTED> doesn't exists in the AST, it's present only in the sexp
Query: origin = '24
sexp: '(query (filters (filter category: (patternFilter field: (patternField) op: (patternOp (equalOp)) value: (patternVal (string (stringContent) (MISSING "\'")))))))'
Right now, Tree-sitter just tries to repair the error so that it can give you back a syntax tree that works for the rest of the file.
https://github.com/tree-sitter/tree-sitter/issues/255
I'll update this comment with more examples very soon.