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: bullet proof APIX response handling #754

Merged
merged 1 commit into from
Jul 15, 2021

Conversation

bryans99
Copy link
Collaborator

@bryans99 bryans99 commented Jul 15, 2021

Description

APIX now renders raw data if it cannot parse the response returned as expected.

Changes

  1. Added try/catches in appropriate places. Note that the try/catch in RunIt is probably NOT necessary but the code being wrapped indicates that an error could be thrown (logically it should never happen as the user should always be authenticated).
  2. Renamed parseJson method to json2Csv to better reflect what it does (I was initially confused by the original method name).
  3. Created a ShowRaw response handler.
  4. Created a fallbackResponseHandler to use ShowRaw.

Screen Shots

image

# Description

APIX now renders raw data if it cannot parse the response returned as expected.

 # Changes

1. Added try/catches in appropriate places. Note that the try/catch in RunIt is probably NOT necessary but the code being wrapped indicates that an error could be thrown (logically it should never happen as the user should always be authenticated).
2. Renamed `parseJson` method to `json2Csv` to better reflect what it does (I was initially confused by the original method name).
3. Created a ShowRaw response handler.
4. Created a fallbackResponseHandler to use ShowRaw.
Copy link
Contributor

@jkaster jkaster left a comment

Choose a reason for hiding this comment

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

This looks great! Very clean implementation. Thank you.

'The response body could not be parsed. Displaying raw data.'
)
).toBeInTheDocument()
expect(screen.getByText('I AM A LYING JSON RESPONSE')).toBeInTheDocument()
Copy link
Contributor

Choose a reason for hiding this comment

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

YES YOU ARE!

@@ -141,6 +137,21 @@ const ShowPDF = (response: IRawResponse) => {
return ShowUnknown(response)
}

/** A handler for responses that cannot be parsed */
const ShowRaw = (response: IRawResponse) => (
Copy link
Contributor

Choose a reason for hiding this comment

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

The door has been opened!

@github-actions
Copy link
Contributor

APIX Tests

    1 files  ±0    75 suites  ±0   2m 46s ⏱️ -11s
286 tests +1  274 ✔️ +1  12 💤 ±0  0 ❌ ±0 
305 runs  +1  293 ✔️ +1  12 💤 ±0  0 ❌ ±0 

Results for commit 03694c8. ± Comparison against base commit 3321bf1.

@bryans99 bryans99 merged commit b2a018a into main Jul 15, 2021
@bryans99 bryans99 deleted the brynryans/apix-bullet-proof-response-handling branch July 15, 2021 00:21
@github-actions

This comment has been minimized.

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

Successfully merging this pull request may close these issues.

2 participants