chore: add logger to track response schema when non 2xx response came…#5038
chore: add logger to track response schema when non 2xx response came…#5038ItsSudip merged 2 commits intohotfix/16hMar2026from
Conversation
… without any error 🔒 Scanned for secrets using gitleaks 8.28.0
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Note
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## hotfix/16hMar2026 #5038 +/- ##
=====================================================
- Coverage 92.32% 92.27% -0.05%
=====================================================
Files 657 656 -1
Lines 36139 35904 -235
Branches 8531 8467 -64
=====================================================
- Hits 33365 33131 -234
+ Misses 2557 2535 -22
- Partials 217 238 +21 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| const processedResponse = processAxiosResponse(clientResponse); | ||
|
|
||
| if (processedResponse.status === HTTP_STATUS_CODES.OK) { | ||
| if (isHttpStatusSuccess(processedResponse.status)) { |
There was a problem hiding this comment.
Why this change? For all 2xx, we are considering success. Don't see anything related to it in PR description.
function isHttpStatusSuccess(status) {
return status >= 200 && status < 300;
}
There was a problem hiding this comment.
Updated the pr description. We shouldn't only consider the 200 as success. We should apply any 2xx as a success scenario. Otherwise, any response that is non-200 but a 2xx, we will apply the error handler on the response, which is not intended.
| } | ||
| throw new Error(`Unexpected: unknown error type ${error}`); | ||
| } | ||
| logger.error(`[facebook_lead_ads_native] Non-OK response from Facebook API`, { |
There was a problem hiding this comment.
Are we sure, we are not going to get anything sensitive in response?
There was a problem hiding this comment.
Yes, we are just logging the schema of the object along with the status code.
| } | ||
| logger.error(`[facebook_lead_ads_native] Non-OK response from Facebook API`, { | ||
| status: processedResponse.status, | ||
| response: JSON.stringify(JsonSchemaGenerator.generate(processedResponse.response)), |
There was a problem hiding this comment.
What's JsonSchemaGenerator? Why do we need it? Can't we simply stringify it?
There was a problem hiding this comment.
JsonSchemaGenerator will generate the schema of the response object. We are using the same approach in source transformation error handling as well.
There was a problem hiding this comment.
Lets log the schema of processedResponse. There might be other fields
|



What are the changes introduced in this PR?
We are getting some unexpected errors, so adding a logger to verify why those error might happen. Along with that, we are considering all 2xx as a success scenario as we can't consider them as failures.
What is the related Linear task?
Resolves INT-6069
Please explain the objectives of your changes below
Put down any required details on the broader aspect of your changes. If there are any dependent changes, mandatorily mention them here
Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?
N/A
Any new dependencies introduced with this change?
N/A
Any new generic utility introduced or modified. Please explain the changes.
N/A
Any technical or performance related pointers to consider with the change?
N/A
@coderabbitai review
Developer checklist
My code follows the style guidelines of this project
No breaking changes are being introduced.
All related docs linked with the PR?
All changes manually tested?
Any documentation changes needed with this change?
Is the PR limited to 10 file changes?
Is the PR limited to one linear task?
Are relevant unit and component test-cases added in new readability format?
Reviewer checklist
Is the type of change in the PR title appropriate as per the changes?
Verified that there are no credentials or confidential data exposed with the changes.