Improve error handling and fix format issues - #5593
Open
murshed wants to merge 1 commit into
Open
Conversation
- Fix serializer error format to be DRF-compliant in OembedRequestSerializer - Add error handling and logging for image dimension fetching in oEmbed endpoint - Add HTTP status check before processing image content - Escape special characters in dag-sync.sh JSON payload for robustness - Update skip button CSS selector for better browser compatibility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix DRF serializer error format, oEmbed exception handling, shell JSON escaping, and skip button focus CSS
Description
This pull request addresses several reliability, compatibility, and accessibility issues across the repository:
Fix serializer error format to be DRF-compliant in
OembedRequestSerializer:Updated the
ValidationErrorerror dictionary structure from{"Could not parse identifier from URL.": data["url"]}to standard DRF-compliant structure{"url": ["Could not parse identifier from URL."]}inapi/api/serializers/image_serializers.py. This aligns with the OpenAPI specification (image_oembed_400_example) and standard PHP / WordPress client expectations.Add error handling and logging for image dimension fetching in oEmbed endpoint:
Wrapped out-of-band image downloading and PIL image dimension parsing in a
try...exceptblock inapi/api/views/image_views.py. Structured warnings (failed_to_get_image_dimensions_for_oembed) are logged when network or parsing errors occur, preventing unhandled HTTP 500 responses.Add HTTP status check before processing image content:
Added explicit
image_file.status == 200verification before reading image content bytes and attempting PIL dimension extraction inimage_views.py.Escape special characters in
dag-sync.shJSON payload for robustness:Added parameter expansion rules
${subject//\\/\\\\}and${subject//\"/\\\"}indag-sync.shto escape backslashes and double quotes in commit messages before constructing Slack webhook JSON payloads.Update skip button CSS selector for better browser compatibility:
Updated the CSS selector in
frontend/src/components/VSkipToContentButton.vueto.skip-button:not(:focus, :focus-visible)so the skip-to-content button is visually displayed whenever focused across all browser focus modes.Testing Instructions
v1/images/oembed/with an invalidurlparameter (e.g.,?url=invalid) and verify that the 400 response body is formatted as{"url": ["Could not parse identifier from URL."]}.v1/images/oembed/for an image whose remote URL returns 404 or times out, and verify that the view returns a valid 200 oEmbed response without throwing a 500 Internal Server Error.bash -n dag-sync.shto verify syntax correctness.Checklist
Update index.md).main) or a parent feature branch.ov just catalog/generate-docsfor catalog PRs) or the media properties generator (ov just catalog/generate-docs media-propsfor the catalog orov just api/generate-docsfor the API) where applicable.Developer Certificate of Origin
Developer Certificate of Origin