Skip to content

Leaderboard request : Field Required missing (date) #16

Description

@GB127

Here is a code snippet :

        print("========================")
        print(game, category)
        test = GetGameLeaderboard2(game, category) # , video=0, values=values_ids)
        print(test.__dict__)
        test = test.perform_all_sync()
        print("test")

Sometimes this code doesn't work in my loop. Here is one that doesn't work:

========================
4pd03de5 jdrq07lk
{'client': <speedruncompy.api.SpeedrunClient object at 0x7a7c285fc350>, 'params': {'params': {'gameId': '4pd03de5', 'categoryId': 'jdrq07lk', 'dateFrom': None, 'dateTo': None, 'emulator': None, 'levelId': None, 'obsolete': None, 'platformIds': None, 'regionIds': None, 'timer': None, 'verified': None, 'values': None, 'video': None}, 'page': None}}

Here is the exception:

Traceback (most recent call last):
  File "/home/guy/Documents/Python_Projects/SRC-statistics/Speedrunner.py", line 29, in <module>
    test = Speedrunner()
           ^^^^^^^^^^^^^
  File "/home/guy/Documents/Python_Projects/SRC-statistics/Speedrunner.py", line 24, in __init__
    self.pbs = PBs(pbs)
               ^^^^^^^^
  File "/home/guy/Documents/Python_Projects/SRC-statistics/Runs.py", line 26, in __init__
    self.append(PB(run.gameId, run.time, run.categoryId, run.valueIds, run.place))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/guy/Documents/Python_Projects/SRC-statistics/entry.py", line 59, in __init__
    test = test.perform_all_sync()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/guy/Documents/Python_Projects/SRC-statistics/env/lib64/python3.12/site-packages/speedruncompy/api.py", line 202, in perform_all_sync
    pages = self._perform_all_raw_sync(retries, delay, autovary, max_pages, **kwargs)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/guy/Documents/Python_Projects/SRC-statistics/env/lib64/python3.12/site-packages/speedruncompy/api.py", line 208, in _perform_all_raw_sync
    return asyncio.run(self._perform_all_raw(retries, delay, autovary, max_pages, **kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/guy/Documents/Python_Projects/SRC-statistics/env/lib64/python3.12/site-packages/speedruncompy/api.py", line 226, in _perform_all_raw
    results = await asyncio.gather(*[self.perform(retries, delay, vary=vary, page=p, **kwargs) for p in range(2, numpages + 1)])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/guy/Documents/Python_Projects/SRC-statistics/env/lib64/python3.12/site-packages/speedruncompy/api.py", line 182, in perform
    return self.return_type.model_validate_json(content.decode(), strict=config.strict_mode)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/guy/Documents/Python_Projects/SRC-statistics/env/lib64/python3.12/site-packages/pydantic/main.py", line 782, in model_validate_json
    return cls.__pydantic_validator__.validate_json(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 2 validation errors for r_GetGameLeaderboard2
runList.57.date
  Field required [type=missing, input_value={'id': 'zg7el8jz', 'gameI...'21g4kwo1', 'jq6k0dvl']}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.13/v/missing
runList.61.date
  Field required [type=missing, input_value={'id': 'yo2n0o5z', 'gameI...'21g4kwo1', 'jq6k0dvl']}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.13/v/missing

But sometimes, the code does work. Here is one print that went all the way:

========================
n268856p jzd35rkn
{'client': <speedruncompy.api.SpeedrunClient object at 0x7a7c285fc350>, 'params': {'params': {'gameId': 'n268856p', 'categoryId': 'jzd35rkn', 'dateFrom': None, 'dateTo': None, 'emulator': None, 'levelId': None, 'obsolete': None, 'platformIds': None, 'regionIds': None, 'timer': None, 'verified': None, 'values': None, 'video': None}, 'page': None}}
test

I think there is an issue with handling the required files in the code... Any ideas? Sometimes it's two entries. Sometimes it's five... Sometimes it's four...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions