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

rphlmr/fixing error handling #840

Merged
merged 88 commits into from
Mar 20, 2024

Conversation

rphlmr
Copy link
Contributor

@rphlmr rphlmr commented Mar 12, 2024

Forks and continue #541

Patch note (partial)

  • loader and action now use parseData helper to validate the request formData/SearchParams/Params and enforce typing + error handling.
  • loader and action now use json(data(...)) and json(error(...))
    • Throwable code have to be surrounded by a try/catch block to properly handle service errors or unhandled errors.
    • Don't throw anything else than ShelfError (like redirect) or it will not work as expected and it will be captured in the catch bloc.
    • In catch bloc:
      • loader should throws json(error(...)) (or return if it is a resource route)
      • action should return json(error(...)) to access actionData.error in useActionData or fetcher.data.
  • tryCreateUser has been removed because wrong usage would result in complete user account deletion.
  • requireOrganisationId renamed to getSelectedOrganisation to better reflect what it does
  • getSelectedOrganisation no longer throws redirect or anything related to the HTTP layer (json).
    • This fix wrong error handling in loader/action or other utils that use it.
    • Default organizationId is the PERSONAL org.
  • error helper (utils/http.server.ts) send a notification of the error it catch.
    It should help catch unhandled action error responses.
  • _layout+ no longer have to handle null user since this case is no longer possible.
  • add a SMTP_FROM env to use in nodemailer because secure SMTP servers reject unknown sender emails
  • settings/team/invite-user now properly handles its loader error and falls back to settings/team ErrorBoundary

Progress:

Routes:

  • ./api+/$organizationId.qr-codes[.zip].ts
  • ./api+/admin.export-org-assets.$organizationId.$fileName[.csv].tsx
  • ./api+/admin.import-org-assets.$organizationId.tsx
  • ./api+/asset.refresh-main-image.ts
  • ./api+/client-notification.ts
  • ./api+/image.$imageId.ts
  • ./api+/model-filters.ts
  • ./api+/oss-friends.ts
  • ./api+/public-stats.ts
  • ./api+/sse.notification.ts
  • ./api+/stripe-webhook.ts
  • ./api+/user.change-current-organization.ts
  • ./api+/user.prefs.dismiss-support-banner.ts
  • ./api+/user.prefs.minimized-sidebar.ts
  • ./api+/user.prefs.skip-onboarding-checklist.ts
  • ./api+/user.prefs.upload-user-photo.ts
  • ./api+/utils.parse-markdown.ts

  • ./_welcome+/_layout.tsx
  • ./_welcome+/onboarding.tsx
  • ./_welcome+/welcome.tsx

  • ./_layout+/$.tsx (moved to ./$.tsx)
  • ./_layout+/_layout.tsx

  • ./_layout+/admin-dashboard+
  • ./_layout+/admin-dashboard+/$userId.tsx
  • ./_layout+/admin-dashboard+/_layout.tsx
  • ./_layout+/admin-dashboard+/announcements.new.tsx
  • ./_layout+/admin-dashboard+/announcements.tsx
  • ./_layout+/admin-dashboard+/org.$organizationId.tsx
  • ./_layout+/admin-dashboard+/users.tsx

  • ./_layout+/assets.$assetId.duplicate.tsx
  • ./_layout+/assets.$assetId.give-custody.tsx
  • ./_layout+/assets.$assetId.note.tsx
  • ./_layout+/assets.$assetId.qr.tsx
  • ./_layout+/assets.$assetId.release-custody.tsx
  • ./_layout+/assets.$assetId.tsx
  • ./_layout+/assets.$assetId.update-location.tsx
  • ./layout+/assets.$assetId.edit.tsx
  • ./_layout+/assets._index.tsx
  • ./_layout+/assets.export.$fileName[.csv].tsx
  • ./_layout+/assets.import.tsx
  • ./_layout+/assets.new.tsx
  • ./_layout+/assets.tsx

  • ./_layout+/bookings.$bookingId.add-assets.tsx
  • ./_layout+/bookings.$bookingId.tsx
  • ./_layout+/bookings.new.tsx
  • ./_layout+/bookings.tsx

  • ./layout+/categories.$categoryId.edit.tsx
  • ./_layout+/categories.new.tsx
  • ./_layout+/categories.tsx

  • ./_layout+/dashboard.tsx

  • ./_layout+/locations.$locationId.add-assets.tsx
  • ./_layout+/locations.$locationId.tsx
  • ./layout+/locations.$locationId.edit.tsx
  • ./_layout+/locations._index.tsx
  • ./_layout+/locations.new.tsx
  • ./_layout+/locations.tsx

  • ./_layout+/settings.account.tsx
  • ./layout+/settings.custom-fields.$fieldId.edit.tsx
  • ./_layout+/settings.custom-fields.index.tsx
  • ./_layout+/settings.custom-fields.new.tsx
  • ./_layout+/settings.custom-fields.tsx
  • ./_layout+/settings.general.tsx
  • ./_layout+/settings.index.tsx
  • ./_layout+/settings.subscription.customer-portal.tsx
  • ./_layout+/settings.subscription.tsx
  • ./_layout+/settings.team.add-member.tsx
  • ./_layout+/settings.team.invite-user.tsx
  • ./_layout+/settings.team.tsx
  • ./_layout+/settings.tsx
  • ./_layout+/settings.workspace.$workspaceId.edit.tsx
  • ./_layout+/settings.workspace.index.tsx
  • ./_layout+/settings.workspace.new.tsx
  • ./_layout+/settings.workspace.tsx

  • ./layout+/tags.$tagId.edit.tsx
  • ./_layout+/tags.new.tsx
  • ./_layout+/tags.tsx

  • ./_auth+/_auth.tsx
  • ./_auth+/accept-invite.$inviteId.tsx
  • ./_auth+/forgot-password.tsx
  • ./_auth+/join.tsx
  • ./_auth+/login.tsx
  • ./_auth+/logout.tsx
  • ./_auth+/otp.tsx
  • ./_auth+/resend-otp.tsx
  • ./_auth+/reset-password.tsx
  • ./_auth+/send-otp.tsx
  • ./_auth+/verify-email.tsx

  • ./healthcheck.tsx

  • ./qr+/$qrId.tsx
  • ./qr+/$qrId_.contact-owner.tsx
  • ./qr+/$qrId_.link.tsx
  • ./qr+/$qrId_.not-logged-in.tsx
  • ./qr+/route.tsx

  • ./_index.tsx

Modules

  • ./asset/service.server.ts

  • ./auth/mappers.server.ts
  • ./auth/service.server.ts

  • ./booking/email-helpers.ts
  • ./booking/service.server.ts
  • ./booking/worker.server.ts

  • ./category/service.server.ts

  • ./custody/service.server.ts

  • ./custom-field/service.server.ts

  • ./invite/service.server.ts

  • ./location/service.server.ts

  • ./organization/context.server.ts
  • ./organization/service.server.ts

  • ./qr/service.server.ts

  • ./report-found/service.server.ts

  • ./scan/service.server.ts
  • ./scan/utils.server.ts

  • ./tag/service.server.ts

  • ./team-member/service.server.ts

  • ./tier/service.server.ts

  • ./user/service.server.test.ts
  • ./user/service.server.ts

DonKoko and others added 30 commits November 7, 2023 16:31
- fixed how error is handled in checkUserAndInviteMatch
- fixed issue in error component
Copy link
Contributor

@DonKoko DonKoko left a comment

Choose a reason for hiding this comment

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

We did quite some testing in staging and we are ready to release this. I am approving the PR.

@DonKoko DonKoko merged commit d9a2116 into Shelf-nu:main Mar 20, 2024
4 checks passed
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.

None yet

2 participants