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

Add graceful fallback response for API calls #328

Merged
merged 1 commit into from
Dec 9, 2020
Merged

Conversation

bru5
Copy link
Contributor

@bru5 bru5 commented Dec 8, 2020

Description

This PR adds an explicit fallback response to avoid page crashing errors on failed API requests, such that the app can handle them more gracefully. For the main API route, the previous behaviour remains for compatibility.

Development notes

An example use case is to avoid page crashes when loading JSON files in place of a real API, without needing to export all of the files for each possible API request. In practice this then allows the metadata panel to be used with a single main JSON file for testing while falling back gracefully for missing data.

All request errors are still visible in the console logs as normal, we could potentially add more information through an additional console.error if needed. Later on if needed, we could also add an error flag to the fallback response.

We could also consider extending this behaviour to the main route too, but for now it remains a special case to retain the previous behaviour (an informative error), avoiding this being a breaking change for that route.

QA notes

Using a public/main JSON test file, test all features that use API requests (first load, pipeline select, metadata panel).

Checklist

  • Read the contributing guidelines
  • Opened this PR as a 'Draft Pull Request' if it is work-in-progress
  • Updated the documentation to reflect the code changes
  • Added new entries to the RELEASE.md file
  • Added tests to cover my changes

Legal notice

  • I acknowledge and agree that, by checking this box and clicking "Submit Pull Request":

  • I submit this contribution under the Apache 2.0 license and represent that I am entitled to do so on behalf of myself, my employer, or relevant third parties, as applicable.

  • I certify that (a) this contribution is my original creation and / or (b) to the extent it is not my original creation, I am authorised to submit this contribution on behalf of the original creator(s) or their licensees.

  • I certify that the use of this contribution as authorised by the Apache 2.0 license does not violate the intellectual property rights of anyone else.

@studioswong
Copy link
Contributor

Great stuff @bru5 !

tested on running viz on a JSON file with setting the meta flag to true ( which is the scenario this fix will cater for, which is enabling the metadata panel while running viz against a JSON file instead of a Kedro project), and it works well!

@bru5 bru5 merged commit c196f03 into main Dec 9, 2020
@bru5 bru5 deleted the feature/api-fallback branch December 9, 2020 10:03
@richardwestenra richardwestenra mentioned this pull request Dec 16, 2020
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants