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

enhance: Detect more cases of network mismatching schema #331

Merged
merged 1 commit into from May 6, 2020

Conversation

ntucker
Copy link
Collaborator

@ntucker ntucker commented May 6, 2020

Fixes #204 .

Motivation

Catching errors earlier is a huge time saver. If these aren't clearly communicated, incorrect data will manifest in ways that can be cumbersome to track down.

Solution

  • Empty string as id is considered invalid (in addition to pre-existing undefined)
  • Detects if the fields passed in are substantially different from what's expected. This usually means you've completely modeled the data wrong.
  • Add status=400 to these errors so they are by default caught by NetworkErrorBoundary

@github-actions
Copy link
Contributor

github-actions bot commented May 6, 2020

Size Change: 0 B

Total Size: 26.9 kB

ℹ️ View Unchanged
Filename Size Change
packages/legacy/dist/index.cjs.js 433 B 0 B
packages/legacy/dist/index.umd.min.js 376 B 0 B
packages/rest-hooks/dist/index.cjs.js 15.6 kB 0 B
packages/rest-hooks/dist/index.umd.min.js 6.94 kB 0 B
packages/test/dist/index.cjs.js 1.86 kB 0 B
packages/use-enhanced-reducer/dist/index.cjs.js 1.08 kB 0 B
packages/use-enhanced-reducer/dist/index.umd.min.js 593 B 0 B

compressed-size-action

@ntucker ntucker merged commit 2af464f into master May 6, 2020
@ntucker ntucker deleted the malformed-detection branch May 6, 2020 06:57
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.

Dev mode error message when API response doesn't match schema
1 participant