Skip to content

Error message with color or UTF8 characters issues #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
niamtokik opened this issue Sep 22, 2023 · 0 comments
Open

Error message with color or UTF8 characters issues #26

niamtokik opened this issue Sep 22, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@niamtokik
Copy link
Owner

When executing a query, data returned by the interfaces are not correctly parsed

{ok, Db} = cozo:open(), 
(fun({error, E}) -> io:format("~p~n", [E]) end)(cozo:run(Db, "?[] <- [[1,2,3,,]]")), 
cozo:close(Db).
[123,34,99,97,117,115,101,115,34,58,91,93,44,34,99,111,100,101,34,58,34,112,
 97,114,115,101,114,58,58,112,101,115,116,34,44,34,100,105,115,112,108,97,121,
 34,58,34,92,117,48,48,49,98,91,51,49,109,112,97,114,115,101,114,58,58,112,
 101,115,116,92,117,48,48,49,98,91,48,109,92,110,92,110,32,32,92,117,48,48,49,
 98,91,51,49,109,215,92,117,48,48,49,98,91,48,109,32,84,104,101,32,113,117,
 101,114,121,32,112,97,114,115,101,114,32,104,97,115,32,101,110,99,111,117,
 110,116,101,114,101,100,32,117,110,101,120,112,101,99,116,101,100,32,105,110,
 112,117,116,32,47,32,101,110,100,32,111,102,32,105,110,112,117,116,32,97,116,
 32,49,53,46,46,49,53,92,110,32,32,32,9581,9472,9472,9472,9472,92,110,32,92,
 117,48,48,49,98,91,50,109,49,92,117,48,48,49,98,91,48,109,32,9474,32,63,91,
 93,32,60,45,32,91,91,49,44,50,44,51,44,44,93,93,32,92,110,32,32,32,183,32,92,
 117,48,48,49,98,91,51,53,59,49,109,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
 32,9650,92,117,48,48,49,98,91,48,109,92,110,32,32,32,9584,9472,9472,9472,
 9472,92,110,34,44,34,102,105,108,101,110,97,109,101,34,58,34,34,44,34,108,97,
 98,101,108,115,34,58,91,123,34,115,112,97,110,34,58,123,34,108,101,110,103,
 116,104,34,58,48,44,34,111,102,102,115,101,116,34,58,49,53,125,125,93,44,34,
 109,101,115,115,97,103,101,34,58,34,84,104,101,32,113,117,101,114,121,32,112,
 97,114,115,101,114,32,104,97,115,32,101,110,99,111,117,110,116,101,114,101,
 100,32,117,110,101,120,112,101,99,116,101,100,32,105,110,112,117,116,32,47,
 32,101,110,100,32,111,102,32,105,110,112,117,116,32,97,116,32,49,53,46,46,49,
 53,34,44,34,111,107,34,58,102,97,108,115,101,44,34,114,101,108,97,116,101,
 100,34,58,91,93,44,34,115,101,118,101,114,105,116,121,34,58,34,101,114,114,
 111,114,34,125]

Even after an explicit conversion to utf8 binary, the string does not look good.

{ok, Db} = cozo:open(), 
(fun({error, E}) -> io:format("~s~n", [<< <<X/utf8>> || X <- E >>]) end)(cozo:run(Db, "?[] <- [[1,2,3,,]]")), 
cozo:close(Db).
{"causes":[],"code":"parser::pest","display":"\u001b[31mparser::pest\u001b[0m\n\n  \u001b[31mÃ\u001b[0m The query parser has encountered unexpected input / end of input at 15..15\n   âââââ\n \u001b[2m1\u001b[0m â ?[] <- [[1,2,3,,]] \n   · \u001b[35;1m               â²\u001b[0m\n   â°ââââ                       \n","filename":"","labels":[{"span":{"length":0,"offset":15}}],"message":"The query parser has encountered unexpected input / end of input at 15..15","ok":false,"related":[],"severity":"error"}

After filtering, colors code are still present.

Filter = fun(X) when X > 255 -> false; (_) -> true end,
{ok, Db} = cozo:open(), 
(fun({error, E}) -> io:format("~p~n", [lists:filter(Filter, E)]) end)(cozo:run(Db, "?[] <- 
[[1,2,3,,]]")), 
cozo:close(Db).
"{\"causes\":[],\"code\":\"parser::pest\",\"display\":\"\\u001b[31mparser::pest\\u001b[0m\\n\\n  \\u001b[31m×\\u001b[0m The query parser has encountered unexpected input / end of input at 15..15\\n   \\n \\u001b[2m1\\u001b[0m  ?[] <- [[1,2,3,,]] \\n   · \\u001b[35;1m               \\u001b[0m\\n   \\n\",\"filename\":\"\",\"labels\":[{\"span\":{\"length\":0,\"offset\":15}}],\"message\":\"The query parser has encountered unexpected input / end of input at 15..15\",\"ok\":false,\"related\":[],\"severity\":\"error\"}"

It could be due to supports_color crate, to termcolor crate or another configuration somewhere. Even after setting NO_COLOR_TERM=1 environment variable, color tags are still printed.

@niamtokik niamtokik added the bug Something isn't working label Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant