fix: resolve CSA Not Eligible 500 when personIdMis is null - #432
Merged
Conversation
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
approved these changes
Aug 5, 2026
plakkara-bc
approved these changes
Aug 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
findLatestPlacementEndDateFromStagingused$queryRawwithWHERE $1 IS NOT NULLwhenpersonIdMiswas null/empty. PostgreSQL returned42P18: could not determine data type of parameter $1, abortingPOST /api/contacts/set-not-eligible.Business rules are unchanged: same
SET_NOT_ELIGIBLEtransition (In Pay → Not Eligible - IP - TBD), cancel code 21, care end date from latest staging placement end date or today.What changed
NULLIF(TRIM(...), ''))parseISODatePacific,parseWklDate) and fall back topacificToday()when missing or invalidpersonIdMisand blank staging end datesHow to test
1-10981225231)npm test -- src/api/contacts/contacts.service.spec.ts -t "cancellation fields on SET_NOT_ELIGIBLE"