Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

umpa-loomp
Copy link

The sites.list() method incorrectly parses the API response, leading to a ValidationError.

The /v2/sites endpoint returns a JSON object with a sites key containing a list of site objects: { "sites": [...] }.

The current implementation attempts to parse this top-level object as a single Site model, which fails because required fields like id are missing at that level.

This commit corrects the behavior by:

  1. Updating the return type hint to List[Site].
  2. Modifying the parsing logic to first extract the list from the sites key before passing it to pydantic.parse_obj_as.

This ensures the method correctly returns a list of Site objects as expected.

The `sites.list()` method incorrectly parses the API response, leading to a `ValidationError`.

The `/v2/sites` endpoint returns a JSON object with a `sites` key containing a list of site objects: `{ "sites": [...] }`.

The current implementation attempts to parse this top-level object as a single `Site` model, which fails because required fields like `id` are missing at that level.

This commit corrects the behavior by:
1. Updating the return type hint to `List[Site]`.
2. Modifying the parsing logic to first extract the list from the `sites` key before passing it to `pydantic.parse_obj_as`.

This ensures the method correctly returns a list of `Site` objects as expected.
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.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.