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

Add an error response event handler to set correct Content-Type header #29 #32

Merged
merged 2 commits into from
Apr 25, 2022

Conversation

ekes
Copy link
Member

@ekes ekes commented Apr 22, 2022

As \Drupal\jsonapi\EventSubscriber\DefaultExceptionSubscriber we need to
supply our own handler for error responses. Unlike jsonapi there are no
strict rules about the content of error responses set by OpenReferral
standard, so we can just encode the Drupal repsonse in JSON and set the
header.

Tests are already covered by the present tests that are on upgrade failing.

As \Drupal\jsonapi\EventSubscriber\DefaultExceptionSubscriber we need to
supply our own handler for error responses. Unlike jsonapi there are no
strict rules about the content of error responses set by OpenReferral
standard, so we can just encode the Drupal repsonse in JSON and set the
header.
@ekes ekes mentioned this pull request Apr 22, 2022
@willguv
Copy link
Member

willguv commented Apr 22, 2022

@ekes is this something we need to let Open Referral know about? Am thinking they could make some modifications to the way they handle errors

@ekes
Copy link
Member Author

ekes commented Apr 22, 2022

@ekes is this something we need to let Open Referral know about? Am thinking they could make some modifications to the way they handle errors

No. The OpenReferral spec is fine. It (the parent spec) gives guidance about the HTTP error codes to return. It then leaves it free to put whatever into the content section (explicitly discussed here openreferral/api-specification#3 )

The error on our end is because our tests have started checking the Content-Type that we were returning errors with - and we were serving them as text not json - which was wrong on our side - because of the missing handler.

…tests.

Used in the error handling service @Serializer is supplied by
serialization.
@willguv
Copy link
Member

willguv commented Apr 22, 2022

Good to know. Cheers for the info

@stephen-cox stephen-cox linked an issue Apr 23, 2022 that may be closed by this pull request
ekes added a commit to localgovdrupal/localgov_directories that referenced this pull request Apr 23, 2022
@ekes
Copy link
Member Author

ekes commented Apr 23, 2022

Simple test fix for Open Referral in Directories will remove that last fail localgovdrupal/localgov_directories#184

Copy link
Member

@stephen-cox stephen-cox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ekes. The failing test is in the localgov_directories_or module which should be fixed with localgovdrupal/localgov_directories#186

Copy link
Member

@finnlewis finnlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge away!

@ekes ekes merged commit 9885609 into 1.x Apr 25, 2022
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.

Fix tests to support PHP 8.1
4 participants