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

Uncaught exception on await Character.items(): KeyError #58

Closed ElReyZero closed 1 year ago

ElReyZero commented 1 year ago

Bug

Exception raised when trying to retrieve a character's items

Current Behavior:

Exception when awaiting a character's items

Expected Behavior:

The function should return the requested character's items

Steps To Reproduce:

Steps to reproduce the behavior:

  1. Set up the auraxium client
  2. Get a character by name or id
  3. Try to do await char.items()

Code example

import auraxium
from auraxium import ps2
import asyncio

async def main():
    async with auraxium.Client() as client:

    char = await client.get_by_name(ps2.Character, 'ElReyZero')
    items = await char.items()
    print(items)

asyncio.run(main())

Full Traceback:

Traceback (most recent call last): File "d:\Users\User\Documents\testing.py", line 29, in asyncio.run(main()) File "D:\Users\User\AppData\Roaming\Python\Python310\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "D:\Users\User\AppData\Roaming\Python\Python310\lib\asyncio\base_events.py", line 641, in run_until_complete return future.result() File "d:\Users\User\Documents\testing.py", line 11, in main print(await char.items()) File "D:\Users\User\AppData\Roaming\Python\Python310\lib\site-packages\auraxium_proxy.py", line 168, in flatten return [e async for e in self] File "D:\Users\User\AppData\Roaming\Python\Python310\lib\site-packages\auraxium_proxy.py", line 168, in return [e async for e in self] File "D:\Users\User\AppData\Roaming\Python\Python310\lib\site-packages\auraxium_proxy.py", line 153, in anext await self._poll() File "D:\Users\User\AppData\Roaming\Python\Python310\lib\site-packages\auraxium_proxy.py", line 71, in poll list = self._resolve_nested_payload(payload) File "D:\Users\User\AppData\Roaming\Python\Python310\lib\site-packages\auraxium_proxy.py", line 129, in _resolve_nested_payload data.extend(resolve_join(join, parent)) File "D:\Users\User\AppData\Roaming\Python\Python310\lib\site-packages\auraxium_proxy.py", line 106, in resolvejoin value = element[f'{on}join{join.data.collection}'] KeyError: 'item_id_join_item'

3.11 Traceback: https://pastebin.com/kpz1SpWL

Environment:

leonhard-s commented 1 year ago

Hi, thanks for the report.

I am unable to reproduce this issue with any of my characters - do you happen to have a character name or ID for which this occured?

I suspect that this may be related to a character that is either very new or deleted (or otherwise bad data), these may not have an entry in the characters_item collection, causing this error.

ElReyZero commented 1 year ago

Sorry for the late response. I'm getting the error even with every character I try, be it new or old. All of those are active characters

leonhard-s commented 1 year ago

There is unfortunately not a lot I can do without being able to repro the issue. Could you share more details about your platform, Auraxium version, or an MRE?

ElReyZero commented 1 year ago

I tried with Python 3.10.2. 3.10.5 and 3.11.0 Auraxium version is 0.2.2 OS: Windows 11

Since Python 3.11 has a better traceback error, here's what I'm getting:

Traceback:

https://pastebin.com/kpz1SpWL

(Edited the issue with a code example)

leonhard-s commented 1 year ago

Resolved in 0.2.3.