Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw 500 and 501 errors for missing or invalid handlers in SCIMMY.Resources.User and SCIMMY.Resources.Group #40

Merged
merged 4 commits into from
Aug 6, 2024

Conversation

sleelin
Copy link
Collaborator

@sleelin sleelin commented Aug 6, 2024

Currently, the read, write, and patch methods of the SCIMMY.Resources.User and SCIMMY.Resources.Group classes pass return values from declared ingress/egress/degress handlers directly to their corresponding schema classes for instantiation. When these handlers are either missing, or do not return expected values, the schema class constructor will throw a TypeError exception, as it expects the supplied value to be an object. This TypeError exception is then rethrown as a SCIMError exception with status and scimType properties of values 400 and invalidValue respectively, indicating an issue with the request, which is technically incorrect.

This change updates the default ingress, egress, and degress handlers for the User and Group resource classes to throw a 501 Not Implemented exception (fixes #39). It also updates the the read and write methods of these classes to throw a 500 Internal Server Error when handler implementations return invalid or empty values that cannot be coerced into schema-compliant values (fixes #39). Additionally, the patch method of these classes have been updated to call the class read and write methods to leverage the aforementioned exception handling, instead of calling ingress/egress handlers themselves (fixes #39). The patch methods have also been updated to require they are only able to be called for a specific resource, instead of for a list of resources. The test fixtures in the resources hooks have been updated to verify the correct exceptions are being thrown, and that the patch method now requires a specific resource.

sleelin added 4 commits August 4, 2024 17:17
…t implemented

This replaces the misleading and incorrect 400 errors currently thrown by the read/write/patch methods when an ingress/egress handler has not been implemented
…turn empty values

This replaces the misleading and incorrect 400 errors currently thrown by the read/write/patch methods when an ingress/egress handler does not return a value
@sleelin sleelin added the bug Something isn't working label Aug 6, 2024
@sleelin sleelin added this to the 1.2.3 milestone Aug 6, 2024
@sleelin sleelin self-assigned this Aug 6, 2024
@sleelin sleelin merged commit d88efeb into main Aug 6, 2024
2 checks passed
@sleelin sleelin deleted the issue/39-resource-handler-missing-returns branch August 6, 2024 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

User and Group resources throwing 400 Bad Request for missing or invalid handler implementations
1 participant