-
Notifications
You must be signed in to change notification settings - Fork 432
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
chore(migration): add better error message when request fails #5567
chore(migration): add better error message when request fails #5567
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
Full Report@sanity/migrate
@sanity/diff
@sanity/block-tools
@sanity/types
sanity/desk
@sanity/portable-text-editor
@sanity/mutator
@sanity/cli
@sanity/util/legacyDateFormat
@sanity/schema/_internal
@sanity/util/paths
sanity/router
@sanity/schema
sanity/structure
sanity/cli
@sanity/vision
@sanity/util/fs
sanity/_internal
@sanity/util/createSafeJsonParser
sanity/_internalBrowser
@sanity/util/content
sanity
|
Component Testing Report Updated Jan 26, 2024 5:49 PM (UTC)
|
25e1c4e
to
a58394c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, thank you!
if (res.status < 200 || res.status > 299) { | ||
const err = new Error(`HTTP Error ${res.status}: ${res.statusText}`) as HTTPError | ||
const response = await res.json() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The json parsing may fail here, should we handle this specifically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that was my first pass with try catch but since it already catches it somewhere else it broke other things but I think I can inline a catch and lot it and it should still throw the error correctly
a58394c
to
1a663f3
Compare
c3d31c8
to
26df627
Compare
1a663f3
to
efabcf9
Compare
26df627
to
6940238
Compare
efabcf9
to
b60c02d
Compare
6940238
to
ab9d42d
Compare
ab9d42d
to
72462a4
Compare
* chore(migration): add better error message when request fails * fix(migration): add error message if json parsing fails
* chore(migration): add better error message when request fails * fix(migration): add error message if json parsing fails
* chore(migration): add better error message when request fails * fix(migration): add error message if json parsing fails
* chore(migration): add better error message when request fails * fix(migration): add error message if json parsing fails
* feat(migrate): move into monorepo from poc * test(migrate): make sure uint8array-extras package gets transpiled from esm * feat(cli): scaffold create/run migration cli commands * fix(migrate): inline functions from uint8array-extras for now Can't be imported from package because of ESM * feat: basic migration cli support * feat: basic `migrations list` command * feat: migration create command w/templates * feat(sanity): add exports for sanity/migrate + sanity/migrate/mutations * chore(migrate): add test script * test(migrate): add tests for `parseJSON` * feat(migrate): add customisable parser and iterator type to `parseJSON` * feat(migrate): add JSON parser that can handle chunks interrupted by an error object * refactor(migrate): rename targets => destinations * feat(migrate): use safe JSON parser when streaming from Export HTTP API (#5542) * refactor(util): create shared JSON parser for `@sanity/export` and `@sanity/migrate` * feat(migrate): add safe JSON parser * chore(util): update comment * chore(export): update comment * feat(migrate): use safe JSON parser when streaming from Export HTTP API * feat(migrate): add JSON options and type parameter to NDJSON utility * refactor(migrate): use type parameter * fix(migrate): add missing export * fix(util): fix package.json formatting * feat(migrate): implement mutation batcher and use when submitting against mutate endpoint * feat(migrate): limit request concurrency * fix(migrate): workaround issue with p-map and ESM * feat(cli): allow user provided concurrency * feat(migration): improve progress as migration is running (#5550) * feat(migration): add a prompt before runing a real migration (#5552) ### Description <!-- What changes are introduced? Why are these changes introduced? What issue(s) does this solve? (with link, if possible) --> Adds a prompt before running a real migration with the projectId and dataset so the user is aware and intentionally selects running a real migration ### What to review <!-- What steps should the reviewer take in order to review? What parts/flows of the application/packages/tooling is affected? --> `sanity migration run <name-of-migration> --dry=false` should show a prompt like "This migration will run on the “test” dataset in “yajkdsl” project. Are you sure?" ### Testing <!-- Did you add sufficient testing for this change? If not, please explain how you tested this change and why it was not possible/practical for writing an automated test --> ### Notes for release <!-- A description of the change(s) that should be used in the release notes. --> - N/A * feat(migration): support passing an array of documentTypes to migration (#5566) * chore(migration): add better error message when request fails (#5567) * chore(migration): add better error message when request fails * fix(migration): add error message if json parsing fails * feat(migrate): add asyncIterableToStream util * feat(migrate): add bufferThroughFile utility * fix(migrate): buffer exports through file * fix(cli): use dryRun from @sanity/migrate * refactor(migrate): rename function * refactor(migrate): add ndjson support for both parsing and stringifying in ndjson util * refactor(sanity): remove mutiny dependency in favor of inlined creators * fix(sanity): add --no-progress flag * fix(migrate): simplify bufferThroughFile * feat(migrate): unify contexts, add support for document lookup and query during a migration * fix(dev): fix example migration script imports * feat(migration): support async hooks in migration nodes (#5564) * fix(sanity): use --no-dry instead of --dry=false * feat(migrate): add support for yielding transactions * fix(migrate): minor typing issue * fix(sanity): polish cli and migration templates * chore(deps): remove unused deps * fix(sanity): fix quoting of documentTypes in migration templates * fix(sanity): rename migration name => title * fix(migrate): run migration against all documents if documentTypes is omitted * fix(migration): fixes dry run not showing any information * fix(migration): show proper error message when the file has code issues * fix(migrate): various naming consistency fixes * fix(sanity): add a few examples to help text for 'sanity migration create' * fix(sanity): improve error handling on 'sanity migration run' without id * fix(migrate): fix error asserting transaction * fix(migrate): use transactionId instead of id on mutation payload * feat(cli): add pretty mutation formatting to migration runner (#5573) * feat(cli): add pretty mutation formatting to migration runner * feat(cli): improve formatting * feat(cli): add indent option to `prettyFormatMutation` * feat(cli): support indentation when printing JSON * feat(cli): support migrations for multiple document types * feat(cli): improve dry run migration formatting * refactor(cli): abstract tree reporter * chore(cli): remove unused import * fix(cli): add missing closing parenthesis * feat(cli): add migration dry-run output * feat(cli): underline document id when pretty formatting mutation * feat(cli): add transaction support to pretty formatter * feat(cli): add transaction support to pretty mutation formatter * refactor(cli): reduce complexity * feat(cli): pretty format mutations when committing migration * chore(migrate): instrument with some debug logging * refactor(migration): move filtered document methods to a separate `filtered`-context key, add a client with limited concurrency to migration context * fix(migrate): add request tags and user agent * fix(sanity): improve minimal example --------- Co-authored-by: Ash <[email protected]> Co-authored-by: Binoy Patel <[email protected]>
Description
Adds the actual error message from the API instead of just HTTP status code. This would be usefull in debugging issues for the end users
Before
After
What to review
Implementation makes sense
Testing
Notes for release
N/A