[BUG] Non-Printable Characters Lead to 'Invalid query'
See original GitHub issueMemgraph version 2.3.1 GQLAlchemy 1.3.1
Describe the bug Non-printable characters like ‘\x13’ lead to ‘Invalid query’
To Reproduce
from gqlalchemy import Memgraph, Node, Field
db = Memgraph()
class Test(Node):
name: str = Field()
Test(name='\x13').save(db)
Expected behavior The str is properly sanitized/escaped or the query ‘just works’.
Logs
CREATE (node:Test) SET node.name = '\x13' RETURN node;
---
gqlalchemy\connection.py", line 93, in execute_and_fetch
cursor.execute(query)
mgclient.DatabaseError: Invalid query.
Additional context I have raw data that I want to load into my graph. Some of my statements fail due to the error above. The error message is not very helpful so I had to debug a bit. I think it could be in the scope of this project to do escaping/sanitizing of non-printable characters, or maybe it is a bug in memgraph itself (Python does not throw any error if I print \x13 😃 ).
At least the error message needs some improvements and more context. Maybe you could print/log the query in case of an error? I also think it would be nice to feature toggle query logging in general.
BR, Alexander
Issue Analytics
- State:
- Created a year ago
- Comments:7 (1 by maintainers)
Top GitHub Comments
I talked with the guys for Memgraph Lab. Actually neither Memgrgaph Lab nor mgconsole meant to handle “raw bytes”. However you can use the
\u0013
form for both of them. For mgconsole the printing will be a bit strange, but it works:For Memgraph Lab the visualization might be also a bit strange, but the test it written and read correctly, check the second screenshot.
@antaljanosbenjamin thank you for your response and further looking into this issue!
I want to add that if I run:
in Memgraph Lab I also get an ‘Invalid query’ response. Here I think it is because of the unescaped ‘\’, but I am not completely sure.
In general I would suggest (to memgraph/memgraph) to improve the invalid query response and provide more detail.
BR, Alexander