Skip to content

fix(integration): stop re-geocoding unchanged addresses and cascading on 429 - #607

Merged
tompscanlan merged 2 commits into
mainfrom
fix/integration-geocode-429
Oct 1, 2026
Merged

tompscanlan merged 2 commits into
mainfrom
fix/integration-geocode-429

Conversation

@tompscanlan

@tompscanlan tompscanlan commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Firehose ingest requests to POST /api/integration/events were taking 5 to 10 seconds. This kept tripping the slow API alert.

The time was spent in Nominatim geocoding:

  • Every update geocoded the location again, even when the record was a re-send with the same address and the event already had coordinates.
  • Nominatim answered most of these with 429. In one 3 hour window, 367 of 465 lookups got a 429.
  • After a 429, the code retried with a shorter address ("Boulder, Boulder, CO, US", then "Boulder, CO, US", then "CO, US", then "US"). Each retry waited 1.1s first.
  • The request had no timeout.

The processing duration metric did not show this, because its timer stops before the update or create step runs.

Change

  • On update, skip geocoding when the address is unchanged and the event already has lat/lon.
  • Return null on the first 429 instead of trying shorter address variants.
  • Add a 5s timeout to the Nominatim request.

Tests

Three new unit tests: unchanged address skips the geocoder, changed address still geocodes, and a 429 makes exactly one request. The first and third fail without this change. The full event-integration.service.spec.ts suite passes (38 tests).

Second fix: PDS handle check (unblocks e2e)

The e2e job started failing because the CI devnet pulls ghcr.io/bluesky-social/pds:0.4, and that tag moved to PDS 0.4.5036 on 2026-09-30. That version answers resolveHandle for a missing handle with error HandleNotFound. Older versions answer with InvalidRequest. isHandleAvailable only accepted the old form, so it threw on every free handle, and no test account got an atproto identity.

isHandleAvailable now accepts both forms. The production PDS is pinned to an older version and still returns InvalidRequest, so this also keeps signup working after a future PDS upgrade.

Checked locally with the CI compose stack and the same PDS image: the 6 suites that failed in CI pass (40 tests).

… on 429

Firehose updates re-sent unchanged records and geocoded the same address
on every update. Nominatim answered with 429, and each 429 fell through
to a shorter address variant with another 1.1s wait, so ingest requests
ran 5-10s and tripped the SlowAPIResponse alert.

- Skip geocoding on update when the address is unchanged and the event
  already has coordinates
- Return null on the first 429 instead of retrying shorter variants
- Add a 5s timeout to the Nominatim request
PDS 0.4.5036 answers resolveHandle for a missing handle with
error "HandleNotFound" instead of "InvalidRequest". isHandleAvailable
only recognized the old form, so it threw on every available handle and
account provisioning never created an atproto identity. Accept both
forms so the check works on the current PDS and on older ones.
@tompscanlan
tompscanlan merged commit e09ede1 into main Oct 1, 2026
4 checks passed
@tompscanlan
tompscanlan deleted the fix/integration-geocode-429 branch October 1, 2026 12:00
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