Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

users.list(include_totals=False) raises ParsingError on a successful 200 response

Đang mở
#856 4 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
68/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
python
Lĩnh vực
api

Hướng nghiên cứu

Bắt đầu tại src/auth0/management/users/raw_client.py trong RawUsersClient.list, sau đó kiểm tra ListUsersOffsetPaginatedResponseContent và reproduction được cung cấp với include_totals=False. Xác nhận rằng response array thành công được chấp nhận và SyncPager trả về các item UserResponseSchema, phù hợp với behavior của include_totals=True.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug
Checklist
  • I have looked into the Readme and have not found a suitable solution or answer.
  • I have looked into the API documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.
Description

ManagementClient.users.list(..., include_totals=False, ...) raises auth0.management.core.parse_error.ParsingError (wrapping a Pydantic ValidationError) on a successful HTTP 200 response from the Management API.

The SDK unconditionally validates the response body against ListUsersOffsetPaginatedResponseContent, which is a dict-shaped Pydantic model. But the Management API — per its public documentation and per the SDK's own docstring — returns a bare JSON array when include_totals=false. The two shapes are incompatible, and there is no branch in the SDK to handle the array case.

Observed

ParsingError: headers: {...}, status_code: 200, body: [{'user_id': 'auth0|...'}], cause: 1 validation error for ListUsersOffsetPaginatedResponseContent
  Input should be a valid dictionary or instance of ListUsersOffsetPaginatedResponseContent [type=model_type, input_value=[{'user_id': 'auth0|...'}], input_type=list]
    For further information visit https://errors.pydantic.dev/2.12/v/model_type

Note the status_code: 200 and the body: [...] (a JSON array). The API responded successfully and in the documented shape; the SDK then failed to parse the response.

Expected

The SyncPager yields UserResponseSchema items, equivalent to the behavior when include_totals=True.

Reproduction
from auth0.management import ManagementClient

client = ManagementClient(domain=..., token=...)

list(client.users.list(
    q='username:"someuser"',
    include_totals=False,
    fields="user_id",
))
Additional context

Root cause

In src/auth0/management/users/raw_client.py, RawUsersClient.list has a single success branch:

https://github.com/auth0/auth0-python/blob/d381cbfa5045ee631ab9eaa458f3dd67d2383b57/src/auth0/management/users/raw_client.py#L135-L143

There is no if include_totals: branch, and the Pydantic model itself is dict-only:

https://github.com/auth0/auth0-python/blob/d381cbfa5045ee631ab9eaa458f3dd67d2383b57/src/auth0/management/types/list_users_offset_paginated_response_content.py#L10-L15

There is no RootModel/list-validation fallback, so parse_obj_as cannot accept the array shape that the API returns.

Contradiction between the SDK's parameter default and the API's contract

The SDK signature:

include_totals: typing.Optional[bool] = True,

…but the SDK's own docstring (copied from the API spec) reads:

Return results inside an object that contains the total result count (true) or as a direct array of results (false, default).

And the public Management API documentation at https://auth0.com/docs/api/management/v2/users/get-users agrees: include_totals=false returns "a direct array of results."

So the API's default behavior (false) is exactly the case the SDK parser cannot handle. This very likely masked the bug in CI — the SDK's own default value (True) takes the only branch the parser supports.

Evidence that the error originates inside the SDK, not from the API

The Auth0 API returned HTTP 200 with the documented response shape. The ParsingError.__str__ formatter in src/auth0/management/core/parse_error.py produces exactly the wire format we see:

def __str__(self) -> str:
    cause_str = f", cause: {self.cause}" if self.cause is not None else ""
    return f"headers: {self.headers}, status_code: {self.status_code}, body: {self.body}{cause_str}"

The cause is a Pydantic ValidationError against ListUsersOffsetPaginatedResponseContent — i.e., the SDK choking on a valid response.

auth0-python version

5.4.0

Python version

3.10

Ngôn ngữ chính
Python
Star
581
Fork
189
Merge trung bình
15 giờ 33 phút
Pull request đã merge (30 ngày)
6

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của auth0/auth0-python

Tất cả issue của auth0/auth0-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.