leonhard-s / auraxium

A high-level Python wrapper for the PlanetSide 2 API.
https://auraxium.readthedocs.io/
MIT License
28 stars 8 forks source link

('experience_bonus',), 'msg': 'value is not a valid integer', 'type': 'type_error.integer'}])> #50

Closed dbrennand closed 3 years ago

dbrennand commented 3 years ago

Hi, I'm using a slightly modified version of a snippet of code from the README.

I have altered: @client.trigger(event.BattleRankUp) to @client.trigger(event.MetagameEvent).

Here is my code:


import asyncio
from auraxium import event, ps2

async def main():

    # Initialise event streaming client to the Planetside 2 Census API
    client = event.EventClient(service_id="s:example")

    # Register client trigger
    @client.trigger(event.MetagameEvent)
    async def show_event(evt):
        print(repr(evt))
        print(evt)

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.create_task(main())
    loop.run_forever()

However, the following error occurs on when an event is received:

auraxium\event\_client.py:167> exception=ValidationError(model='MetagameEvent', errors=[{'loc': ('experience_bonus',), 'msg': 'value is not a valid integer', 'type': 'type_error.integer'}])>

Is my usage incorrect?

leonhard-s commented 3 years ago

Hi, this looks like a problem with pydantic, not your code.

Auraxium uses a pydantic model for all messages it receives to validate and parse them into the object model representation. This gem of a message is its way of complaining about bad types. I have created an issue for this lack of information; this really should not result in a user-facing error message as this is not provoked by your code (#51).

It looks like there are alerts whose experience type is a float or other non-integer type. I started logging a session, but it might take a while before we get an alert violating the constraint. I confirmed that this was the issue, a fix is underway.

leonhard-s commented 3 years ago

The issue with your snippet has been resolved. Similar data model incompatibilities should now also result in a more helpful error message that also includes the offending payload to make correcting the model faster. Thank you for the report!