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(migrate): fixes error message to be more helpful #6986

Merged

Conversation

binoy14
Copy link
Contributor

@binoy14 binoy14 commented Jun 18, 2024

Description

Seems like the error response from backend is in the shape below

{ error: { type: string, description: string }

When we receive error in this shape we don't properly log that message making it hard for folks to debug. See screenshots below

Before

Screenshot 2024-06-18 at 2 49 06 PM

After

Screenshot 2024-06-18 at 2 49 32 PM

What to review

Copy and change makes sense, I checked the repo and there seems to be other places checking error.description so I am not sure if error will not be an object but I added a conditional to keep backwards compatibility

Testing

Updated the test

Notes for release

  • Migration error messages provide more details

Copy link

vercel bot commented Jun 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
page-building-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 18, 2024 7:05pm
performance-studio ✅ Ready (Inspect) Visit Preview Jun 18, 2024 7:05pm
test-compiled-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 18, 2024 7:05pm
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 18, 2024 7:05pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 18, 2024 7:05pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Jun 18, 2024 7:05pm

Copy link
Contributor Author

binoy14 commented Jun 18, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @binoy14 and the rest of your teammates on Graphite Graphite

Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Jun 18, 2024

Component Testing Report Updated Jun 18, 2024 7:08 PM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 37s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 7s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 26s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 32s 11 7 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 14s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 9s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 44s 2 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 36s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 16s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 5s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 7s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 21s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 15s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 30s 12 0 0

Copy link
Contributor

@ricokahler ricokahler left a comment

Choose a reason for hiding this comment

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

had a few ✨ suggestions but this is already better so ✅

Comment on lines +47 to +58
const mockResponse = {
status: 500,
statusText: 'Internal Server Error',
json: () =>
Promise.resolve({
error: {
type: 'validationError',
description: 'Document is not of valid type',
},
status: 500,
}),
}
Copy link
Contributor

Choose a reason for hiding this comment

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

If our env supports the response constructor, this may be nicer

Suggested change
const mockResponse = {
status: 500,
statusText: 'Internal Server Error',
json: () =>
Promise.resolve({
error: {
type: 'validationError',
description: 'Document is not of valid type',
},
status: 500,
}),
}
const mockResponse = new Response(
JSON.stringify({
error: {
type: 'validationError',
description: 'Document is not of valid type',
},
status: 500,
}),
{
status: 500,
statusText: 'Internal Server Error',
},
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

probably worth doing it but maybe in a follow up PR, would need to change a few tests

@binoy14 binoy14 added this pull request to the merge queue Jun 18, 2024
Merged via the queue into next with commit df89f88 Jun 18, 2024
44 checks passed
@binoy14 binoy14 deleted the 06-18-fix_migrate_fixes_error_message_to_be_more_helpful branch June 18, 2024 20:07
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.

2 participants