mirror of
https://github.com/tr4nt0r/python-xbox.git
synced 2026-04-24 23:36:08 +03:00
[GH-ISSUE #85] Validation errors for PresenceItem #3
Labels
No labels
👻 bug
🐣 good first issue
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/python-xbox#3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @tomballgithub on GitHub (Jan 21, 2026).
Original GitHub issue: https://github.com/tr4nt0r/python-xbox/issues/85
I am using a script that relies on 'xbox-webapi-python', but I noticed that your fork is actually maintained, so I thought I'd bring my issue here.
The issue is that within
pythonxbox\api\provider\presence\__init__.py, I am getting errors, even with your code base, of:1 validation error for PresenceItem devices.0.titles.1.activity Input should be a valid array [type=list_type, input_value={'richPresence': 'The City: The Theater'}, input_type=dict] For further information visit https://errors.pydantic.dev/2.12/v/list_typeThe line that causes the issues is the last one in
get_presence:return PresenceItem.model_validate_json(resp.text)I noticed that the response from Xbox does not give an error when it's like this:
but it does give an error when it's this:
The part that is causing the error is this:
'activity': { 'richPresence': 'The City' },And if I change the last line to the following, removing the 'activity' section, it no longer fails:
This page from Microsoft shows a sample PresenceRecord response that includes the 'activity' section:
https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/live/rest/uri/presence/uri-usersmegetAnd if I force that exact response into get_presence as follows, it also generates errors for the 'activity' section:
The errors:
And these errors are pydantic not liking something about what should be a valid JSON from Xbox.
How to formally solve?
@tr4nt0r
This repo is using Opire - what does it mean? 👇
💵 Everyone can add rewards for this issue commenting
/reward 100(replace100with the amount).🕵️♂️ If someone starts working on this issue to earn the rewards, they can comment
/tryto let everyone know!🙌 And when they open the PR, they can comment
/claim #85either in the PR description or in a PR's comment.🪙 Also, everyone can tip any user commenting
/tip 20 @tomballgithub(replace20with the amount, and@tomballgithubwith the user to tip).📖 If you want to learn more, check out our documentation.
@tomballgithub commented on GitHub (Jan 21, 2026):
The fix is to edit
pythonxbox\api\provider\presence\models.pyfrom:activity: list[ActivityRecord] | None = Noneto
activity: ActivityRecord | None = NoneThe activity record is defined as being a dict rather than a list. The current code is looking for a list.
https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/live/rest/json/json-titlerecord
@tr4nt0r commented on GitHub (Jan 21, 2026):
Yeah, I forked
python-xbox-webapibecause it is unmaintained and I also had to fix some outdated models. This fork has now replaced the library in the Home Assistant integration. Please feel free to open a bugfix PR, I will release a new version to pypi as soon as it is merged.@tomballgithub commented on GitHub (Jan 22, 2026):
@tr4nt0r I submitted a PR for this