Skip to content

fix(platform): close the #3806 cloud import and bulk send findings - #3905

Merged
yannickmonney merged 3 commits into
mainfrom
fix/cloud-import-raw-error-bulk-send-reason
Sep 29, 2026
Merged

yannickmonney merged 3 commits into
mainfrom
fix/cloud-import-raw-error-bulk-send-reason

Conversation

@yannickmonney

Copy link
Copy Markdown
Contributor

Follow-up to #3806 (one failure, one toast), from its review. Each of the three open items was re-checked on main before coding. #3784, which the brief says overlaps the bulk-send item, has since merged, so the bulk-send change builds on it.

What changed

1. Cloud import never shows the provider's raw answer (OneDrive, SharePoint, Google Drive)

When a person imports a selected folder, collectAllFiles lists that folder again. A success: false answer to that walk was thrown as a plain Error. failureDetail returns a plain Error's message as-is, so the import toast showed the provider's own text under the localized Import failed / Sync failed. Before the fix, the new test got this toast:

- "description": "Something went wrong — try again, or reload the page if it keeps happening.",
+ "description": "OneDrive API error: 403 {\"error\":{\"code\":\"accessDenied\"}}",

What changed, in both onedrive-import-dialog.tsx and google-drive-import-dialog.tsx:

  • The walk now throws CloudListingError, the class the picker's listings already use (queries.ts).
  • The catch logs that error's message with console.warn and shows common.errors.generic.
  • Every other error still goes through failureDetail:
    • A refusal keeps its words.
    • A lapsed session reads common.errors.sessionEnded.
    • The localized documents.onedrive.folderTooLargeToImport still shows.
  • An import answered success: false no longer shows its error field. That field is the backend's English, and in practice it is always the grant check's sentence (tokenFor in the import routes). The toast reads common.errors.generic, and result.error goes to the log.

2. The bulk summaries carry the first refusal's words (en/de/fr)

Each send in a bulk send is quiet at its hook (errorToast: false). The summary toast is therefore its only report, and it gave only the counts.

handleSendMessages now collects the rejected reasons in selection order. When any send failed, it appends firstFailureDetail(reasons) to the counts through a new key, conversations.bulk.outcomeWithReason ('{outcome} — {reason}'), in en/de/fr. What that reason reads:

  • A conversation without a contact email: panel.contactEmailNotFound, in the page's language.
  • A door refusal: the door's own words.
  • A fault (a 5xx): nothing is added.

Found by the sweep, same concept and same file: a status verb whose batch was refused beside answered batches also gave only counts. #3784 names the reason only when nothing changed. runStatusVerb now appends failureDetail(outcome.firstError) through the same key.

The Inbox guide (EN/DE/FR docs/*/platform/index.md) and the CONV-F34 box now say that the message gives the first failure's reason.

3. The SharePoint listings are proven as the KNOW-B16 row claims

cloud-import-dialogs.listing-failure.test.tsx now drives each SharePoint listing (the sites, a site's libraries, a library's files) through the real query and adapter row, with three answers each:

Answer Result the test checks
success: false exactly one title-only Couldn't load items, after three attempts
a refusal one toast with the refusal's words
a lapsed grant (the sentence resolveGraphTokenForUser sends) onRequireConnect is called and no toast is raised

The same file drives the import walk for OneDrive, SharePoint and Google Drive with three answers: a raw answer, a refusal, and a folder too large to list.

Manual-layer updates in tests/manual/reference/automation.md:

  • The KNOW-B16 row names the listings it covers.
  • A new row covers the import path.
  • The CONV-F10/F28/F34 row and the "one failure, one toast" row cover the bulk summaries.

How I verified it

All local runs used a sandbox shared with other agents (load average up to about 140 on 4 cores). Workspace-wide gates are left to CI.

Tests with the change (all green):

Files Tests
cloud-import-dialogs.listing-failure.test.tsx 24
onedrive-import-dialog.test.tsx 10
google-drive-import-dialog.test.tsx 9
cloud-import-dialogs.lapsed-session.test.tsx 12
documents-table.test.tsx + use-listing-failure-toast.test.ts 11
use-bulk-actions.test.ts + use-bulk-actions.send-summary.test.tsx 36
home-inbox-list.wire.test.tsx + home-inbox-list.test.tsx + conversations.test.tsx (these import the bulk hook), counted together with the row above 68 in total
guards (error-message-description, single-failure-toast) + lib/i18n/messages.test.ts 85, re-run after rebasing on 5b10a3c57
docs locale/prose/link checks (services/docs, 7 files) 38

Negative controls (new tests run against the unfixed code):

  • Dialogs at HEAD: 7 failures. These are the three walk cases (OneDrive, SharePoint, Google Drive) plus two per dialog test file. All 36 other tests pass.
  • use-bulk-actions.ts at HEAD: 11 failures. These are every en/de/fr summary case plus the status-verb partial-refusal case.

Mutations on onedrive-import-dialog.tsx. Each row removes one useListingFailureToast call (sites / drives / SharePoint files) or drops one listing from isMicrosoftAccountError.

Mutation Before this PR After this PR
sites toast survived caught
drives toast survived caught
SharePoint files toast survived caught
sites handoff survived caught
drives handoff caught by the one existing drives test caught
SharePoint files handoff survived caught

After this PR, each mutation is caught by exactly the test for its own listing.

Static checks:

  • oxlint --type-aware on the changed files: clean.
  • oxfmt --check: clean.
  • Scoped tsc over the changed files and what they import: clean.
  • bun run lint:manual: ok.
  • check-guide.ts on conversations.md: OK. It reports no new findings on automation.md.

Left open, for a decision rather than this PR

  • A lapsed grant on the import path. Such a grant, on the folder walk or the import itself, now reads Import failed with common.errors.generic. Before, it read the English sentence "…is not authorized for importing. Connect … from Documents." The listings hand a lapsed grant to the connect dialog instead. Doing the same on the import path (for example, isCloudImportAuthError(error) → handleDisconnected()) would be a small follow-up, but it changes the flow, so I left it out.
  • A partly failed import. An import where some files failed (success: false with a failedCount and no error) still reads Import failed with the generic line, even when most files landed. This is unchanged from before.
  • firstFailureDetail reads only the first failure. When the first failure is a fault and a later one is a refusal, the summary shows counts only. This is the shared helper's existing behaviour, and every batch surface uses it.

Importing a selected folder lists it again. A success: false answer to
that walk was thrown as a plain Error, so the import's toast showed the
provider's own text under the localized Import failed, such as
`OneDrive API error: 403 {"error":…}`. An import answered success: false
showed its error field, the backend's English.

The walk now throws a CloudListingError, as the picker's listings do.
The catch logs its message and shows common.errors.generic; a refusal
keeps its words through failureDetail, and a folder too large to list
keeps its localized sentence. An unsuccessful import answer reads the
generic line too, and its error goes to the log. The OneDrive,
SharePoint and Google Drive walks are covered through the real adapter
rows.
The listing-failure proof covered the files listings and one lapsed
grant on the SharePoint drives listing, while the automation register
claimed every SharePoint listing. Removing the sites, drives or files
listing toast failed no test, nor did dropping the sites or files
listing from the lapsed-grant check.

Each SharePoint listing (the sites, a site's libraries, a library's
files) now answers success: false, a refusal and a lapsed grant through
the real query and adapter row: one title-only toast after three
attempts, one toast with the refusal's words, and a handoff to the
connect dialog with no toast. The KNOW-B16 row names the listings it
covers.
Each send of a bulk send is quiet at its hook, so the summary toast is
the only report of a refused send, and it gave the counts alone. A
status verb whose batch was refused beside answered ones did the same;
only a verb that changed nothing said why.

Both summaries now add the first refusal's words after the counts
through conversations.bulk.outcomeWithReason in English, German and
French, read through firstFailureDetail and failureDetail. A
conversation without a contact email reads in the page's language, a
door's refusal in its own words, and a fault adds nothing. The Inbox
guide and the manual layer say so.
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.

1 participant