Skip to content

fix(ui): handle rejected document uploads without fetch error page (REGBACKLOG-476) - #1938

Merged
panish16 merged 2 commits into
mainfrom
feature-REGBACKLOG-476-upload-error
Nov 28, 2026
Merged

panish16 merged 2 commits into
mainfrom
feature-REGBACKLOG-476-upload-error

Conversation

@panish16

@panish16 panish16 commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Issue:

Description of changes:

  • examiner-web: the document store no longer rethrows after showing the upload error modal. BaseUploadAdditionalDocuments calls await emit('uploadDocument', ...), and emit doesn't return the handler's promise, so the rethrown error went unhandled into Nuxt's global error handler and showed the full-page "Fetch Error". Host and strata already swallow it after the modal. This path only became reachable after feat(upload): enhance document upload validation for PDF and JPEG for… #1905, because the API now rejects files whose contents don't match the declared type (e.g. a PDF renamed to .jpg).
  • host-pm-web / strata-web (Pam asked to check the host side): on a failed dashboard upload, addDocument calls removeStoredDocument for a doc that was never added to storedDocuments. findIndex returned -1, and splice(-1, 1) removed the last real document from the list. On host it then also saves a draft when permit.application is loaded. Fixed in fix(ui): simplify failed-upload cleanup + version bumps (REGBACKLOG-476) #1939 (stacked into this branch): the failed-upload catch no longer calls removeStoredDocument, since the doc was never added. This replaced an index === -1 guard that SonarCloud flagged as duplicated code.

How this was tested:

  • Unit / integration tests run:
    • examiner: updated store-document.spec.ts (upload failure now resolves and still shows the modal). Lint passes; 310 pass, 8 skipped.
    • host: new regression test in store-document.spec.ts. It fails without the fix and passes with it. Lint passes; 344/344 pass.
    • strata: lint passes; 49 pass, 13 skipped.
    • use-filing-history.spec.ts (examiner) and strata-formatting.spec.ts (strata) sometimes time out in a setup hook locally. That happens on clean main too, unrelated to this change.
  • Manual / local / DB verification:
    • Deployed this branch to dev (examiner, host and strata UI CDs all green).
    • Host, dev: registration H178304639 (NOC expired), uploaded a PDF renamed to .pdf.jpg as "Property tax notice". API returned 400 File contents do not match the file type 'image/jpeg' (POST /registrations/359/documents in strr-api-dev logs). Only the error modal showed: no Fetch Error, no refresh needed, all 5 existing docs still listed.
    • Examiner, dev: still to do. I couldn't get through IDIR on dev yet; will update here once it's tested.
    • The upload panel still closes after a failed upload, the same as after a successful one, because of the same await emit problem. Checking with Pam on the Jira ticket whether that's OK for the "remains on the upload page" acceptance criterion.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the BC Registry and Digital Services BSD 3-Clause License

…EGBACKLOG-476)

- examiner: stop rethrowing upload errors from the document store; the error
  modal is already shown and the rethrow escaped through emit() into Nuxt's
  global error handler, showing the "Fetch Error" page
- host/strata: removeStoredDocument returns early when the doc isn't in the
  list, so a rejected dashboard upload no longer splices(-1) the last stored
  document (and, on host, saves a draft without it)
@bcregistry-sre

Copy link
Copy Markdown
Collaborator

Temporary Url for review: https://strr-strata-hotel-dev--pr-1938-4j4maije.web.app

@bcregistry-sre

Copy link
Copy Markdown
Collaborator

Temporary Url for review: https://strr-examiner-dev--pr-1938-kqjlqgjc.web.app

@bcregistry-sre

Copy link
Copy Markdown
Collaborator

Temporary Url for review: https://strr-hosts-dev--pr-1938-otwohg7o.web.app

Comment thread strr-host-pm-web/app/stores/document.ts Resolved
Comment thread strr-host-pm-web/app/stores/document.ts Resolved
Comment thread strr-host-pm-web/app/stores/document.ts Resolved
Comment thread strr-strata-web/app/stores/document.ts Resolved
panish16 added a commit that referenced this pull request Nov 27, 2026
- base: guard removeDocumentFromList against index -1 (bump base to 0.0.64)
- examiner: JSDoc says upload fns always resolve; add addDocumentToApplication failure test
- strata: add rejected dashboard upload test (list unchanged, no DELETE)
…76) (#1939)

* chore(ui): bump examiner, host and strata versions (REGBACKLOG-476)

* fix(ui): drop removeStoredDocument from failed dashboard upload catch (REGBACKLOG-476)

The doc is only pushed to storedDocuments as the last step of the try, so on
failure there is nothing to remove. Calling it with a doc not in the list hit
splice(-1, 1) and dropped the last stored doc. Replaces the index === -1 guard
(Sonar flagged the duplicated guard in host/strata).

* fix(ui): address #1938 review (REGBACKLOG-476)

- base: guard removeDocumentFromList against index -1 (bump base to 0.0.64)
- examiner: JSDoc says upload fns always resolve; add addDocumentToApplication failure test
- strata: add rejected dashboard upload test (list unchanged, no DELETE)

* fix(ui): keep the not-found guard in removeStoredDocument (REGBACKLOG-476)

findIndex returns -1 for a doc that's not in the list (double click on
remove, or removed while its upload was still running), and splice(-1, 1)
then drops the last real document. Return early in host and strata, with
a regression test in each.
@sonarqubecloud

Copy link
Copy Markdown

@bcregistry-sre

Copy link
Copy Markdown
Collaborator

Temporary Url for review: https://strr-strata-hotel-dev--pr-1938-4j4maije.web.app

@bcregistry-sre

Copy link
Copy Markdown
Collaborator

Temporary Url for review: https://strr-examiner-dev--pr-1938-kqjlqgjc.web.app

@bcregistry-sre

Copy link
Copy Markdown
Collaborator

Temporary Url for review: https://strr-hosts-dev--pr-1938-otwohg7o.web.app

@panish16
panish16 merged commit cc6db54 into main Nov 28, 2026
52 checks passed

This branch was previously deployed

1 inactive deployment
dev — 0d800459 Deployed Nov 27, 2026 by panish16 via strata-ui-cd / deploy #372
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.

3 participants