Open martijnthe opened 1 week ago
Hi, thank you for opening this issue! Definitely a bug, I'll take a look later or early next week 😌
Wrote a test in #152, which passes. There is also no MessageCode
in v0.8.1, are you sure you're using that version?
There is also no MessageCode in v0.8.1, are you sure you're using that version?
Yes. Looking at the backtrace, MessageCode
seems to be coming from the dacite
dependency.
Hi @martijnthe,
Could you provide a raw failing event json like from your screen capture above? I may have mis-transcribed something when I tried to replicate your issue:
from dataclasses import dataclass
from dacite import from_dict
from enum import Enum
from typing import Optional
from axiom_py.query import QueryResult, MessagePriority
import json
testcase = {
"format": "legacy",
"status": {
"elapsedTime": 0,
"blocksExamined": 0,
"rowsExamined": 0,
"rowsMatched": 0,
"numGroups": 0,
"isPartial": False,
"continuationToken": None,
"isEstimate": None,
"minBlockTime": None,
"maxBlockTime": None,
"messages": [
{
"priority": MessagePriority.WARN,
"count": 1,
"code": "apl_possibly_causing harm which is bad - sorry martin!",
"msg": "line 5, col 20 where clause evaluates to computer says no"
}
],
"minCursor": None,
"maxCursor": None,
}
}
def dataclass_to_dict(obj):
if hasattr(obj, "__dataclass_fields__"):
return {k: dataclass_to_dict(v) for k, v in obj.__dict__.items()}
elif isinstance(obj, list):
return [dataclass_to_dict(i) for i in obj]
elif isinstance(obj, Enum):
return obj.value
else:
return obj
user = from_dict(QueryResult, testcase)
as_json = dataclass_to_dict(user)
print(json.dumps(as_json))
Oddly no direct reference to MessageCode
that I can see in the axiom python SDK for v0.8.1 or recent revisions so wondering how you could have produced the trace above. What output do you get from the script attached?
By running:
$ python3 test.py | jq
I get a JSON document as follows:
{
"request": null,
"status": {
"elapsedTime": 0,
"blocksExamined": 0,
"rowsExamined": 0,
"rowsMatched": 0,
"numGroups": 0,
"isPartial": false,
"continuationToken": null,
"isEstimate": null,
"minBlockTime": null,
"maxBlockTime": null,
"messages": [
{
"priority": "warn",
"count": 1,
"code": "apl_possibly_causing harm which is bad - sorry martin!",
"msg": "line 5, col 20 where clause evaluates to computer says no"
}
],
"maxCursor": null,
"minCursor": null
},
"matches": null,
"buckets": null,
"tables": null,
"dataset_names": [],
"savedQueryID": null
}
If you can an error/exception that would be interesting.
Python version for the above:
$ python --version
Python 3.13.0
Another useful check would be:
pip show axiom_py
And make sure the version is v0.7 or more recent. Prior to v0.7 MessageCode
as indicated by
your trace was a valid dataclass so you could be picking up a stale version of the library in your
environment.
Please let us know how you get along @martijnthe
Library version: v0.8.1
When including
where true
in an APL query, the library crashes with this exception:See below for the full backtrace.
In the Axiom webapp/console, the query runs fine. I do see a warning in the response:
Even though it's a useless query clause, the library shouldn't crash on the response.
The same happens with
where false
, but then the value that the library chokes on isapl_whereclausealwaysevaluatestoFALSEwhichwillexcludealldata_5
.