Skip to content

AuthorizationError does not say whether it was a 401 or a 403 #805

Closed

Description

@tobixen

Disclaimer: AI-generated text below the line, generated by Claude Opus 5.5, from the prompt:

yes [to drafting caldav issues for two findings of the calendaring 2.1 code review]


base_client._raise_authorization_error() builds the AuthorizationError from url, reason, preconditions and body. The HTTP status is dropped. A caller cannot tell "bad or missing credentials" (401) from "authenticated, but not allowed" (403) except by guessing from the reason phrase, which servers word freely.

calendaring maps these to two different exceptions (AuthenticationError and AuthorizationError). It currently reads exc.status, so today every 401 ends up as an authorisation error: PyCalendar/calendaring#13.

Suggested fix: set status on the exception, from reason_source.status (niquests/requests) or reason_source.status_code (httpx). It could go on DAVError generally, since error_from_response() has the response at hand too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions