fix: align UserPrincipal with the /v1/me contract (username, nullable email)#5
Conversation
…ullable email) UserClient.me() raised a pydantic ValidationError against the current backend: UserPrincipal declared name: str and email: str, but GET /v1/me returns username (not name), and email is null when the account has no email set. Every me() call to a backend on that contract crashed. Rename the field to username and make email optional to match the wire shape, and update the fixture, tests, and docs. Verified against a live backend: me() now returns the username with a null email cleanly. This renames a public field on UserPrincipal (name -> username). me() never succeeded against a backend on the current contract, so no working caller depended on the old field.
There was a problem hiding this comment.
Code Review
This pull request updates the UserPrincipal model and related documentation, tests, and fixtures to replace the name field with username and make the email field optional (nullable). These changes align the SDK with the backend's updated response schema. No review comments were provided, so there is no additional feedback to address.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
rogercloud
left a comment
There was a problem hiding this comment.
Non-blocking: python/src/xagent_sdk/user_client.py:67 still documents UserClient.me() as returning the old /v1/me shape with email / name. This PR updates the public contract to username plus nullable email, and the dataclass, fixture, README, and tests are aligned with that. Please update this method docstring as well so the API docs do not keep advertising the removed name field.
…il shape The me() method docstring still listed the old `email` / `name` fields. Align it with UserPrincipal's actual shape: `username` plus a nullable `email`.
Problem
UserClient.me()raises a pydanticValidationErroragainst the currentbackend.
UserPrincipaldeclared:but
GET /v1/mereturnsusername(notname) andemailisnullwhen the account has no email set:
{"principal_type":"user","user_id":1,"username":"administrator","email":null,"key_prefix":"..."}So every
me()call to a backend on this contract fails on twovalidation errors (
emailnot a string,namemissing). The old shapewas modeled on an earlier backend that returned
name+ a non-nullemail; the contract has since changed and the SDK was not updated.Fix
Match the wire shape:
UserPrincipal.name→usernameUserPrincipal.email→str | NoneUpdated the
me_user.jsonfixture, unit tests (incl. a newemail == nullcase), the e2e assertion, and the docs.Compatibility
This renames a public field (
UserPrincipal.name→username) and makesemailoptional.me()never succeeded against a backend on the currentcontract, so no working caller depended on the old field.
Validation
me()now returnsusername='administrator',email=Nonewithout error.