Skip to content

Crash when using where true query #151

@martijnthe

Description

@martijnthe

Library version: v0.8.1

When including where true in an APL query, the library crashes with this exception:

ValueError: 'apl_whereclausealwaysevaluatestoTRUEwhichwillincludealldata_5' is not a valid MessageCode

See below for the full backtrace.

In the Axiom webapp/console, the query runs fine. I do see a warning in the response:
image

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 is apl_whereclausealwaysevaluatestoFALSEwhichwillexcludealldata_5.

  File "/home/redacted/.venv/lib/python3.10/site-packages/axiom/client.py", line 272, in query
    result = Util.from_dict(QueryResult, res.json())
             │              │            └ <Response [200]>
             │              └ <class 'axiom.query.result.QueryResult'>
             └ <class 'axiom.util.Util'>
  File "/home/redacted/.venv/lib/python3.10/site-packages/axiom/util.py", line 34, in from_dict
    return dacite.from_dict(data_class=data_class, data=data, config=cfg)
           │                           │                │            └ Config(type_hooks={<enum 'QueryKind'>: <enum 'QueryKind'>, <class 'datetime.datetime'>: <bound method Util.convert_string_to_dat...
           │                           │                └ {'format': 'legacy', 'status': {'elapsedTime': 5707, 'minCursor': '0d5aufdk9qf40-0779121980003ba2-00000001', 'maxCursor': '0d5b2...
           │                           └ <class 'axiom.query.result.QueryResult'>
           └ <module 'dacite' from '/home/redacted/.venv/lib/python3.10/site-packages/dacite/__init__.py'>
  File "/home/redacted/.venv/lib/python3.10/site-packages/dacite/core.py", line 64, in from_dict
    value = _build_value(type_=field_type, data=field_data, config=config)
    │       │                  │                │                  └ Config(type_hooks={<enum 'QueryKind'>: <enum 'QueryKind'>, <class 'datetime.datetime'>: <bound method Util.convert_string_to_dat...
    │       │                  │                └ {'elapsedTime': 5707, 'minCursor': '0d5aufdk9qf40-0779121980003ba2-00000001', 'maxCursor': '0d5b230gs1ds0-0779121bf500433c-00000...
    │       │                  └ <class 'axiom.query.result.QueryStatus'>
    │       └ <function _build_value at 0x765fee897d90>
    └ QueryLegacy(startTime=datetime.datetime(2024, 9, 2, 19, 51, 22, 393873, tzinfo=datetime.timezone.utc), endTime=datetime.datetime...
  File "/home/redacted/.venv/lib/python3.10/site-packages/dacite/core.py", line 99, in _build_value
    data = from_dict(data_class=type_, data=data, config=config)
    │      │                    │           │            └ Config(type_hooks={<enum 'QueryKind'>: <enum 'QueryKind'>, <class 'datetime.datetime'>: <bound method Util.convert_string_to_dat...
    │      │                    │           └ {'elapsedTime': 5707, 'minCursor': '0d5aufdk9qf40-0779121980003ba2-00000001', 'maxCursor': '0d5b230gs1ds0-0779121bf500433c-00000...
    │      │                    └ <class 'axiom.query.result.QueryStatus'>
    │      └ <function from_dict at 0x765fee895d80>
    └ {'elapsedTime': 5707, 'minCursor': '0d5aufdk9qf40-0779121980003ba2-00000001', 'maxCursor': '0d5b230gs1ds0-0779121bf500433c-00000...
  File "/home/redacted/.venv/lib/python3.10/site-packages/dacite/core.py", line 64, in from_dict
    value = _build_value(type_=field_type, data=field_data, config=config)
    │       │                  │                │                  └ Config(type_hooks={<enum 'QueryKind'>: <enum 'QueryKind'>, <class 'datetime.datetime'>: <bound method Util.convert_string_to_dat...
    │       │                  │                └ [{'priority': 'warn', 'count': 1, 'code': 'apl_whereclausealwaysevaluatestoTRUEwhichwillincludealldata_5', 'msg': 'line: 5, col:...
    │       │                  └ typing.List[axiom.query.result.Message]
    │       └ <function _build_value at 0x765fee897d90>
    └ '2024-11-01T18:33:00Z'
  File "/home/redacted/.venv/lib/python3.10/site-packages/dacite/core.py", line 97, in _build_value
    data = _build_value_for_collection(collection=type_, data=data, config=config)
    │      │                                      │           │            └ Config(type_hooks={<enum 'QueryKind'>: <enum 'QueryKind'>, <class 'datetime.datetime'>: <bound method Util.convert_string_to_dat...
    │      │                                      │           └ [{'priority': 'warn', 'count': 1, 'code': 'apl_whereclausealwaysevaluatestoTRUEwhichwillincludealldata_5', 'msg': 'line: 5, col:...
    │      │                                      └ typing.List[axiom.query.result.Message]
    │      └ <function _build_value_for_collection at 0x765fee8b4670>
    └ [{'priority': 'warn', 'count': 1, 'code': 'apl_whereclausealwaysevaluatestoTRUEwhichwillincludealldata_5', 'msg': 'line: 5, col:...
  File "/home/redacted/.venv/lib/python3.10/site-packages/dacite/core.py", line 154, in _build_value_for_collection
    return data_type(_build_value(type_=item_type, data=item, config=config) for item in data)
           │         │                  │                            │                   └ [{'priority': 'warn', 'count': 1, 'code': 'apl_whereclausealwaysevaluatestoTRUEwhichwillincludealldata_5', 'msg': 'line: 5, col:...
           │         │                  │                            └ Config(type_hooks={<enum 'QueryKind'>: <enum 'QueryKind'>, <class 'datetime.datetime'>: <bound method Util.convert_string_to_dat...
           │         │                  └ <class 'axiom.query.result.Message'>
           │         └ <function _build_value at 0x765fee897d90>
           └ <class 'list'>
  File "/home/redacted/.venv/lib/python3.10/site-packages/dacite/core.py", line 154, in <genexpr>
    return data_type(_build_value(type_=item_type, data=item, config=config) for item in data)
                     │                  │               │            │           └ {'priority': 'warn', 'count': 1, 'code': 'apl_whereclausealwaysevaluatestoTRUEwhichwillincludealldata_5', 'msg': 'line: 5, col: ...
                     │                  │               │            └ Config(type_hooks={<enum 'QueryKind'>: <enum 'QueryKind'>, <class 'datetime.datetime'>: <bound method Util.convert_string_to_dat...
                     │                  │               └ {'priority': 'warn', 'count': 1, 'code': 'apl_whereclausealwaysevaluatestoTRUEwhichwillincludealldata_5', 'msg': 'line: 5, col: ...
                     │                  └ <class 'axiom.query.result.Message'>
                     └ <function _build_value at 0x765fee897d90>
  File "/home/redacted/.venv/lib/python3.10/site-packages/dacite/core.py", line 99, in _build_value
    data = from_dict(data_class=type_, data=data, config=config)
    │      │                    │           │            └ Config(type_hooks={<enum 'QueryKind'>: <enum 'QueryKind'>, <class 'datetime.datetime'>: <bound method Util.convert_string_to_dat...
    │      │                    │           └ {'priority': 'warn', 'count': 1, 'code': 'apl_whereclausealwaysevaluatestoTRUEwhichwillincludealldata_5', 'msg': 'line: 5, col: ...
    │      │                    └ <class 'axiom.query.result.Message'>
    │      └ <function from_dict at 0x765fee895d80>
    └ {'priority': 'warn', 'count': 1, 'code': 'apl_whereclausealwaysevaluatestoTRUEwhichwillincludealldata_5', 'msg': 'line: 5, col: ...
  File "/home/redacted/.venv/lib/python3.10/site-packages/dacite/core.py", line 64, in from_dict
    value = _build_value(type_=field_type, data=field_data, config=config)
    │       │                  │                │                  └ Config(type_hooks={<enum 'QueryKind'>: <enum 'QueryKind'>, <class 'datetime.datetime'>: <bound method Util.convert_string_to_dat...
    │       │                  │                └ 'apl_whereclausealwaysevaluatestoTRUEwhichwillincludealldata_5'
    │       │                  └ <enum 'MessageCode'>
    │       └ <function _build_value at 0x765fee897d90>
    └ 1
  File "/home/redacted/.venv/lib/python3.10/site-packages/dacite/core.py", line 91, in _build_value
    data = config.type_hooks[type_](data)
    │      │                 │      └ 'apl_whereclausealwaysevaluatestoTRUEwhichwillincludealldata_5'
    │      │                 └ <enum 'MessageCode'>
    │      └ Config(type_hooks={<enum 'QueryKind'>: <enum 'QueryKind'>, <class 'datetime.datetime'>: <bound method Util.convert_string_to_dat...
    └ 'apl_whereclausealwaysevaluatestoTRUEwhichwillincludealldata_5'
  File "/home/redacted/lib/python3.10/enum.py", line 385, in __call__
    return cls.__new__(cls, value)
           │           │    └ 'apl_whereclausealwaysevaluatestoTRUEwhichwillincludealldata_5'
           │           └ <enum 'MessageCode'>
           └ <enum 'MessageCode'>
  File "/home/redacted/lib/python3.10/enum.py", line 710, in __new__
    raise ve_exc
          └ None
ValueError: 'apl_whereclausealwaysevaluatestoTRUEwhichwillincludealldata_5' is not a valid MessageCode

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions