Skip to content

fix: Nominatim location sync — User-Agent policy + diagnostic logging#1966

Open
Asi0Flammeus wants to merge 1 commit intodevfrom
fix/nominatim-location-sync-debugging
Open

fix: Nominatim location sync — User-Agent policy + diagnostic logging#1966
Asi0Flammeus wants to merge 1 commit intodevfrom
fix/nominatim-location-sync-debugging

Conversation

@Asi0Flammeus
Copy link
Copy Markdown
Collaborator

@Asi0Flammeus Asi0Flammeus commented Mar 20, 2026

Problem

Event/project location sync fails silently for new locations. The .catch(() => null) swallowed all errors, making diagnosis impossible.

Root cause identified: Nominatim returns HTTP 429 (rate limit) with an HTML error page instead of JSON. The code calls res.json() on this HTML, crashing with SyntaxError: Unexpected token '<'. This happens because requests were fired in a tight loop with no delay, violating Nominatim's 1 req/s policy.

Solution

  1. 1.1s delay between requests — respects Nominatim's max 1 req/s rate limit
  2. User-Agent header — required by Nominatim usage policy (requests without it get 403)
  3. HTTP status check (res.ok) — throws a clear error on non-200 responses instead of crashing on HTML parsing

Tested locally

Ran a full content sync against the public Nominatim API with the fix applied:

  • 186 event locations resolved successfully
  • 21 project locations resolved successfully
  • Zero 429 errors with the 1.1s delay
  • Confirmed that without the delay, requests get rate-limited after ~15-20 requests

@trigger-xyz
Copy link
Copy Markdown
Collaborator

trigger-xyz commented Mar 20, 2026

Does this works locally on your computer @Asi0Flammeus ? Plz run it locally, and fix the issue.

Root cause: Nominatim returns HTML on 429 rate limit, causing
res.json() to crash with SyntaxError. Requests fired in a tight
loop with no delay.

- Add 1.1s delay between requests (Nominatim policy: max 1 req/s)
- Add User-Agent header (required by Nominatim usage policy)
- Check res.ok before parsing response to avoid crash on errors
- Remove debug console.log from fetch functions

Tested locally: 186 event + 21 project locations resolved, zero 429s.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Asi0Flammeus Asi0Flammeus force-pushed the fix/nominatim-location-sync-debugging branch from 29e90f1 to dbc90fb Compare March 28, 2026 17:36
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