fix: guard publicReportUpdateAddressID against empty GID+Raw #151

Merged
eliribble merged 1 commit from issue-149-publicreport-address-guard into main 2026-07-20 17:27:04 +00:00
Member

When the frontend submits an address update with both GID and Raw empty (e.g., user clicked the map and continued before the async reverse geocode completed, or the reverse geocode failed), the else branch in publicReportUpdateAddressID falls through to:

SELECT id FROM public.address WHERE gid = '' LIMIT 1

On organization 1 this matches address 68 (the first address inserted with gid = ''), which was likely created during early development/MVCAC demos. The result: every report submitted through the door-hanger (district) path with an incomplete address gets attached to this same address, causing the unrelated-reports issue Alysia reported.

Fix: Add an early return guard at the top of publicReportUpdateAddressID when both GID and Raw are empty. No address data to set, so leave the report's address_id unchanged.

See issue #149 comment for the full root-cause analysis.

When the frontend submits an address update with both GID and Raw empty (e.g., user clicked the map and continued before the async reverse geocode completed, or the reverse geocode failed), the else branch in `publicReportUpdateAddressID` falls through to: ```sql SELECT id FROM public.address WHERE gid = '' LIMIT 1 ``` On organization 1 this matches address 68 (the first address inserted with `gid = ''`), which was likely created during early development/MVCAC demos. The result: every report submitted through the door-hanger (district) path with an incomplete address gets attached to this same address, causing the unrelated-reports issue Alysia reported. **Fix:** Add an early return guard at the top of `publicReportUpdateAddressID` when both GID and Raw are empty. No address data to set, so leave the report's address_id unchanged. See issue #149 comment for the full root-cause analysis.
fix: guard publicReportUpdateAddressID against empty GID+Raw
All checks were successful
/ golint (push) Successful in 12s
/ pnpm-build (push) Successful in 32s
479496e326
When both GID and Raw are empty, the else branch executes
`WHERE address.gid = '' LIMIT 1`, which picks whatever address was
first inserted with an empty GID column. On organization 1 this happens
to be address 68, resulting in dozens of unrelated reports all being
attached to it.

Adding an early return guard prevents this fallthrough and ensures that
submitting an address with no data leaves the report's address_id
unchanged.
eliribble approved these changes 2026-07-20 17:26:59 +00:00
eliribble deleted branch issue-149-publicreport-address-guard 2026-07-20 17:27:04 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Gleipnir/nidus-sync!151
No description provided.