feat(ApiException): log source headers inside APIException #228
Merged
andrii-bodnar merged 1 commit intocrowdin:mainfrom Dec 19, 2025
Merged
feat(ApiException): log source headers inside APIException #228andrii-bodnar merged 1 commit intocrowdin:mainfrom
andrii-bodnar merged 1 commit intocrowdin:mainfrom
Conversation
Easier to debug `ValidationError` from the server as they do not provide enough details
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #228 +/- ##
=======================================
Coverage 99.35% 99.35%
=======================================
Files 178 178
Lines 8225 8225
Branches 185 185
=======================================
Hits 8171 8171
Misses 39 39
Partials 15 15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
andrii-bodnar
approved these changes
Dec 19, 2025
Member
andrii-bodnar
left a comment
There was a problem hiding this comment.
@dhoko thank you for the contribution, looks good to me!
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.
👋 Hello,
When we try to upload a file to the API, it can fail for an unexpected issue -> the filename of the source we try to upload.
The API gives us this error
I was not expecting the API to crash on the storage step because the filepath was wrong.
I thought we uploaded a blob at this stage, and the filename of the source didn't matter. It was a random blob uploaded to get an id we could use when we assign the file later. I was wrong 🙈
I found this inside the source:
Sadly, the error doesn't tell us enough details, to know what we sent was wrong. The idea is to bind the source headers inside the exception so we have the data we need to understand the error, at least way faster than today 😁
it gives us:
{ "details": { "crowdin": { "headers": { "Date": "Thu, 18 Dec 2025 15:32:18 GMT", "Content-Type": "application/json", "Transfer-Encoding": "chunked", "Connection": "keep-alive", "Server": "nginx", "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Methods": "GET, POST, OPTIONS, DELETE, PATCH, PUT", "Access-Control-Allow-Headers": "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,ETag,Accept,AcceptEncoding,Authorization,Crowdin-API-FileName,X -Crowdin-Integrations-User-Agent", "Access-Control-Allow-Credentials": "true", "Strict-Transport-Security": "max-age=31536000; includeSubdomains" }, "source_headers": { "Content-Type": "application/json", "Crowdin-API-FileName": "source-2025-12-18_16:32.json" }, "data": { "errors": [ { "error": { "key": "Crowdin-API-FileName", "errors": [ { "code": "regexNotMatch", "message": "File name can't contain any of the following characters: \\ / : * ? \" < > |" } ] } } ] }, "http_code": 400, "raw": "ValidationError: http_status=400, request_id=None, detail: None, context=b'{\"errors\":[{\"error\":{\"key\":\"Crowdin-API-FileName\",\"errors\":[{\"code\":\"regexNotMatch\", \"message\":\"File name can\\'t contain any of the following characters: \\\\\\\\ \\\\/ : * ? \\\\\" < > |\"}]}}]}'" } } }