fix: check H3Cell error and use proper string value in publicReportUpdateLocation #161

Merged
eliribble merged 1 commit from issue-160-h3cell-bad-data into main 2026-07-23 04:40:43 +00:00
Member

Fixes issue #160.

Two bugs in publicReportUpdateLocation:

  1. Discarded error: location.H3Cell() returned (cell, error) but the error was silently discarded with _. When invalid coordinates produced a zero-value cell (H3_NULL / Cell 0), the error was lost and the bad data was stored.

  2. Wrong value type: The H3cell column is a postgres.ColumnString, but the SET clause used postgres.Int(int64(*h3cell)). For valid cells this happened to work because PostgreSQL casts integer literals to h3index, but for cell 0 it stored 0 — an invalid h3index string that crashes on read via H3Index.Scan().

Fix: Check the H3Cell error and return it wrapped. Use postgres.String(h3cell.String()) to pass the proper hex string representation.

Fixes issue #160. Two bugs in `publicReportUpdateLocation`: 1. **Discarded error:** `location.H3Cell()` returned `(cell, error)` but the error was silently discarded with `_`. When invalid coordinates produced a zero-value cell (H3_NULL / Cell 0), the error was lost and the bad data was stored. 2. **Wrong value type:** The `H3cell` column is a `postgres.ColumnString`, but the SET clause used `postgres.Int(int64(*h3cell))`. For valid cells this happened to work because PostgreSQL casts integer literals to h3index, but for cell 0 it stored `0` — an invalid h3index string that crashes on read via `H3Index.Scan()`. **Fix:** Check the H3Cell error and return it wrapped. Use `postgres.String(h3cell.String())` to pass the proper hex string representation.
fix: check H3Cell error and use proper string value in publicReportUpdateLocation
Some checks failed
/ golint (push) Successful in 19s
/ pnpm-build (push) Failing after 3s
f27a40391b
Two bugs in publicReportUpdateLocation:
1. The error from location.H3Cell() was silently discarded with _,
   allowing invalid coordinates to pass through and store a zero H3
   cell (Cell 0 / H3_NULL) in the database.
2. The H3cell column is a postgres.ColumnString, but the SET was
   using postgres.Int(int64(*h3cell)). For valid cells this happened
   to work because PostgreSQL casts integer literals to h3index, but
   for cell 0 it stored '0' — an invalid h3index that fails on read.

Fix: check the error from H3Cell() and return it wrapped, and use
postgres.String(h3cell.String()) to pass the proper hex string
representation that the h3index type expects.
eliribble approved these changes 2026-07-23 04:40:36 +00:00
eliribble deleted branch issue-160-h3cell-bad-data 2026-07-23 04:40:43 +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!161
No description provided.