Skip to content

Include Error object in SCIMResponseErrorObject #37

Description

@NaqGuug

Currently SCIMResponseErrorObject just reads the Error object and prints information to the message. However, it would be beneficial to also store the object into the exception in case we want to handle the error somewhere else and access the Error there.

For example, in FastAPI we could override the exception with @app.exception_handler(SCIMResponseErrorObject) and return json according to the rfc.

Example code if this is implemented

@app.exception_handler(SCIMResponseErrorObject)
async def scim_response_error_object_handler(_request: Request, exc: SCIMResponseErrorObject):
    return JSONResponse(
        status_code=exc.error.status,
        content=exc.error.model_dump(),
    )

Activity

  1. added theissue type on Feb 4, 2026
  2. azmeuk commented on Feb 4, 2026

    @azmeuk
    Member

    Thank you for the bug report.

    It would definitively be feasible to provide the Error object in the exceptions.

    However, after the exceptions overhaul in scim2-models, I am tempted to re-use the exceptions it provides directly, this would allow to use except SCIMException or filter more precisely, such as except UniquenessException. However that would mean abandoning or reworking the SCIMResponseErrorObject and SCIMRequestErrorObject distinction. 🤔

    The error object could be accessed by exc.to_error().

  3. NaqGuug commented on Feb 4, 2026

    @NaqGuug
    Author

    Yeah, honestly the most important thing is that we can create or access the corresponding Error object from exceptions and vice versa. So it would be totally fine if the client raises SCIMException instead of SCIMResponseErrorObject

  4. azmeuk commented on Feb 4, 2026

    @azmeuk
    Member

    I will probably do it in a cleaner way later, in the meantime there is a .to_error() method in the scim2-client exceptions (that matches the scim2-models method). This is released in 0.7.3

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions