Skip to content

fix: align UserPrincipal with the /v1/me contract (username, nullable email)#5

Merged
AlexLiu190625 merged 2 commits into
xorbitsai:mainfrom
AlexLiu190625:fix/me-username-shape
Jun 10, 2026
Merged

fix: align UserPrincipal with the /v1/me contract (username, nullable email)#5
AlexLiu190625 merged 2 commits into
xorbitsai:mainfrom
AlexLiu190625:fix/me-username-shape

Conversation

@AlexLiu190625

Copy link
Copy Markdown
Collaborator

Problem

UserClient.me() raises a pydantic ValidationError against the current
backend. UserPrincipal declared:

email: str
name: str

but GET /v1/me returns username (not name) and email is null
when 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 two
validation errors (email not a string, name missing). The old shape
was modeled on an earlier backend that returned name + a non-null
email; the contract has since changed and the SDK was not updated.

Fix

Match the wire shape:

  • UserPrincipal.nameusername
  • UserPrincipal.emailstr | None

Updated the me_user.json fixture, unit tests (incl. a new
email == null case), the e2e assertion, and the docs.

Compatibility

This renames a public field (UserPrincipal.nameusername) and makes
email optional. me() never succeeded against a backend on the current
contract, so no working caller depended on the old field.

Validation

  • Full unit suite green; mypy strict + ruff + codespell clean.
  • Verified against a live backend: me() now returns
    username='administrator', email=None without error.

…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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 rogercloud left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`.
@AlexLiu190625 AlexLiu190625 merged commit 3e66c03 into xorbitsai:main Jun 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants