feat(ApiException): log source headers inside APIException #228
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: \\\\\\\\ \\\\/ : * ? \\\\\" < > |\"}]}}]}'" } } }