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

Change the HTTP gateway for ChainAPI test calls #1794

Merged
merged 4 commits into from
Jun 16, 2023
Merged

Conversation

dcroote
Copy link
Contributor

@dcroote dcroote commented Jun 2, 2023

Closes #1738

Changes made for HTTP gateway requests:

  1. Return data from successful API calls that fail processing
  2. Make reserved parameters inaccessible in pre/post processing

For 1, a new type, HttpGatewayApiCallPartialResponse, was added for the scenario of a HTTP gateway request that returns data from the API call but fails processing. Within this type there is an errorMessage field and success is set to true, which is necessary to bubble the data field (API response) back up through the call stack.

For 2, only preProcessApiSpecifications was modified. No changes were made to postProcessApiSpecifications because post processing only takes the raw API response data and endpoint array (for extraction of postProcessingSpecifications) as inputs and not reserved parameters:

const goPostProcessApiSpecifications = await go(() => postProcessApiSpecifications(rawResponse.data, endpoint));

Changes:
- Return data from successful API calls that fail processing
- Make reserved parameters inaccessible in pre/post processing
@dcroote dcroote self-assigned this Jun 2, 2023
@bbenligiray
Copy link
Member

post processing only takes the raw API response data and endpoint array (for extraction of postProcessingSpecifications) as inputs and not reserved parameters

Related: #1673

@dcroote
Copy link
Contributor Author

dcroote commented Jun 14, 2023

The conclusion of this discussion is to proceed with merging this and make reserved parameters inaccessible in post processing later when they get passed to post processing as part of #1673 (they are currently not passed to post processing).

@dcroote dcroote requested review from amarthadan and andreogle and removed request for amarthadan, andreogle and bbenligiray June 15, 2023 05:05
@dcroote dcroote requested a review from bbenligiray June 15, 2023 05:17
packages/airnode-node/src/api/processing.ts Outdated Show resolved Hide resolved

if (payload.type === 'http-gateway') {
// Add back reserved parameters for the HTTP gateway special case
parameters = Object.entries(aggregatedApiCall.parameters).reduce((params, [key, value]) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same with this. maybe worth adding a general function to remove reserved parameters from an object?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line being commented on is where reserved parameters are added back rather than removed, but I know what you mean so I added two functions: one to remove reserved parameters and one to re-insert them after processing

@dcroote dcroote requested a review from andreogle June 16, 2023 06:21
Copy link
Member

@andreogle andreogle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change HTTP Gateway for ChainAPI test calls
3 participants