Skip to content

Ssi 1253 hr objects are not valid as a react child found object error - #580

Open
sam-drumm wants to merge 3 commits into
developmentfrom
SSI-1253-hr-objects-are-not-valid-as-a-react-child-found-object-error
Open

Ssi 1253 hr objects are not valid as a react child found object error#580
sam-drumm wants to merge 3 commits into
developmentfrom
SSI-1253-hr-objects-are-not-valid-as-a-react-child-found-object-error

Conversation

@sam-drumm

@sam-drumm sam-drumm commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes Sentry error on the staff assessment tab after a failed PATCH. Also closes the same crash on other save paths that catch a failure and put it in the error banner.

The Sentry event fired when staff changed band / bidding number → PATCH 400 (reserved or duplicate bidding number) → white screen. The assessment form stored the caught Error object in state and rendered it in the error summary. React cannot render an object as a child, so it throws React error as reported.

Fixes

Assessment tab

  • Keep a string in submitError instead of the Error object (this is the crash).
  • updateApplication now uses the API message when present (e.g. reserved bidding number), otherwise Unable to update application (${status}).
  • After a successful save, router.replace() instead of router.reload(), so the browser cannot restore old radio values over the fresh page (PATCH 200, then values revert on reload noticed in testing). onSubmit returns the promise so Formik clears isSubmitting. enableReinitialize picks up server-assigned bidding numbers after the refetch.
  • Coupled with ConsistentRead on the API (PR) so the refetch returns the updated record.

User-facing errors vs technical errors

toUserErrorMessage always returns a string, so React is never handed an Error as a child.

  • Errors we wrote are shown as-is: thunk rejectWithValue strings (e.g. Unable to create verify code (500)) and UserFacingError from the housing API (e.g. reserved bidding number).
  • Browser failures (dropped connection, invalid JSON) are not shown to the user. The page gets the fallback copy for that screen; the original error is console.error'd so it still reaches Sentry via the console integration in instrumentation-client.ts.

Resident apply

Sign-in, verify, and declaration catch a failed request and put the result in the error banner. That is fine when the failure is already a string. It is not fine when it is an Error (network drop, invalid JSON). Those pages now go through toUserErrorMessage. HTTP errors still display the same copy as before.

Health tab (medical details)

PATCH 400 then unhandled rejection. Staff could send an empty form-received date, which the API rejects. The field is now required, the PATCH is awaited, failures show in an error summary and do not reload.

Screenshot 2026-09-04 at 10 06 10

Other staff actions

  • Add note: check res.ok, throw, return the Formik promise, show error, do not reload on failure.
  • Assign user / sensitive data: show the API or fallback message instead of swallowing the catch.
  • Add case / edit household member: same helper, so a dropped connection does not crash the page or show Failed to fetch.

Test plan

  • Assessment: save with a reserved/duplicate bidding number — banner shows the API message, no white screen, form stays usable.
  • Assessment: successful save — radios/band match the saved values (no revert).
  • Medical details: empty form-received date is blocked client-side; a failed PATCH shows the summary and does not reload.
  • Sign-in / verify: HTTP 500 still shows the existing copy; a dropped network shows the generic message, not Failed to fetch.
  • Add note / assign / sensitive: failure stays on the page with an error; success still reloads.

@sam-drumm
sam-drumm requested a review from a team as a code owner September 2, 2026 14:47
>
{({
isSubmitting,
// , errors, isValid

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

these were never used anyway so cleaned

@sonarqubecloud

sonarqubecloud Bot commented Sep 4, 2026

Copy link
Copy Markdown

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