Skip to content

fix: resolve CSA Not Eligible 500 when personIdMis is null - #432

Merged
plakkara-bc merged 3 commits into
devfrom
fix/csa-not-eligible-staging-query
Aug 5, 2026
Merged

fix: resolve CSA Not Eligible 500 when personIdMis is null#432
plakkara-bc merged 3 commits into
devfrom
fix/csa-not-eligible-staging-query

Conversation

@mdiapenabc

Copy link
Copy Markdown
Collaborator

The staging care-end lookup used untyped null parameters in $queryRaw, which PostgreSQL rejected with 42P18. Build ICM/MIS branches only when the corresponding person id is present, ignore blank staging dates, and safely fall back to today when no valid end date is found.

Description

Fixes Internal Server Error when users click CSA Not Eligible on an In Pay record

Root cause: findLatestPlacementEndDateFromStaging used $queryRaw with WHERE $1 IS NOT NULL when personIdMis was null/empty. PostgreSQL returned 42P18: could not determine data type of parameter $1, aborting POST /api/contacts/set-not-eligible.

Business rules are unchanged: same SET_NOT_ELIGIBLE transition (In Pay → Not Eligible - IP - TBD), cancel code 21, care end date from latest staging placement end date or today.

What changed

  • Build ICM/MIS staging lookup branches only when the corresponding person id is present (avoids untyped null parameters in raw SQL)
  • Exclude blank staging placement end dates (NULLIF(TRIM(...), ''))
  • Parse staging dates with existing Pacific helpers (parseISODatePacific, parseWklDate) and fall back to pacificToday() when missing or invalid
  • Add unit tests for null/blank personIdMis and blank staging end dates

How to test

  • Open CSA → Eligibility List → filter In Pay → select a record (e.g. 1-10981225231)
  • Click CSA Not Eligible → expect 200 (no Internal Server Error)
  • Confirm status → Not Eligible - IP - TBD, cancel code 21, care end date populated
  • Add record to batch as Cancellation → should succeed
  • Run npm test -- src/api/contacts/contacts.service.spec.ts -t "cancellation fields on SET_NOT_ELIGIBLE"

The staging care-end lookup used untyped null parameters in $queryRaw,
which PostgreSQL rejected with 42P18. Build ICM/MIS branches only when
the corresponding person id is present, ignore blank staging dates, and
safely fall back to today when no valid end date is found.
@plakkara-bc
plakkara-bc merged commit fd2f3f6 into dev Aug 5, 2026
15 checks passed
@plakkara-bc
plakkara-bc deleted the fix/csa-not-eligible-staging-query branch August 5, 2026 02:58
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.

2 participants