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

fix: harmonize HTTP gateway response object when encoding fails #1859

Merged
merged 2 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eighty-items-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@api3/airnode-node': patch
---

Harmonize HTTP gateway response object when encoding fails compared to when it succeeds
5 changes: 4 additions & 1 deletion packages/airnode-node/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,10 @@ export async function processSuccessfulApiCall(
const log = logger.pend('ERROR', goExtractAndEncodeResponse.error.message);
// The HTTP gateway is a special case for ChainAPI where we return data from a successful API call that failed processing
if (payload.type === 'http-gateway') {
return [[log], { success: true, errorMessage: goExtractAndEncodeResponse.error.message, data: rawResponse.data }];
return [
[log],
{ success: true, errorMessage: goExtractAndEncodeResponse.error.message, data: { rawValue: rawResponse.data } },
];
}
return [[log], { success: false, errorMessage: goExtractAndEncodeResponse.error.message }];
}
Expand Down
2 changes: 1 addition & 1 deletion packages/airnode-node/test/e2e/http.feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('processHttpRequest', () => {
const [_err, result] = await processHttpRequest(modifiedConfig, endpointId, minimalParameters);

const expected: HttpGatewayApiCallResponse = {
data: { result: '723.39202' },
data: { rawValue: { result: '723.39202' } },
success: true,
errorMessage: `Invalid type: ${invalidType}`,
};
Expand Down