Skip to content

fix(events): serve only published, placed events in the geojson feed - #1167

Merged
Ardnived merged 4 commits into
mainfrom
fix/geojson-feed-region-less-drafts
Nov 16, 2026
Merged

Ardnived merged 4 commits into
mainfrom
fix/geojson-feed-region-less-drafts

Conversation

@Ardnived

@Ardnived Ardnived commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Live preview of a Region or Event shows the Atlas error screen (Sentry SAHAJATLAS-WEB-2, 31 events since 2026-11-15, all on sahajatlas.com preview loads).

A live-preview request lifts the published-only access clause, so GET /api/events/geojson also returns drafts. Payload skips required on a draft save, so a draft that was never published can have no region. The widget's AgnosticFeedEventSchema expects region to be an object, so one null fails the whole feed parse. The view boundary then renders the error.

Production has exactly two such rows, both drafts that were never published: events 1932 (Cornwall, CA) and 2002 (empty). They match the two zod issues in the Sentry event ([444].properties.region, [487].properties.region). The same leak also put every unpublished draft (47 today) on every previewed map.

Fix

The feed now ANDs two clauses onto every read, next to notFinishedWhere:

  • _status: published, for every caller, including a live-preview request. The previewed document never needed the feed: the widget renders it from its own draft=true read, and frames its map marker from that read too. A Region preview now shows the events a visitor would see.
  • region exists. Publishing enforces required, but deleting a region nulls events.region_id (ON DELETE SET NULL). Such an event would fail the widget's parse for every visitor, not just in preview.

Like the finished-events filter, both run inside the read, so totalDocs and pagination stay correct, and a caller's where cannot opt out. The OpenAPI description documents both.

Tests

New cases in events-geojson.int.spec.ts › drafts and region-less events:

  • A guard that shows the preview token does unlock drafts on an ordinary events read, so the next case cannot pass vacuously.
  • A live-preview request gets no draft, with or without a region.
  • A published event whose region is gone is not served.

I removed each clause in turn and confirmed its own case fails: expected [3, 2, 1] to not include 3 without PUBLISHED, and expected [5, 2, 1] to not include 5 without PLACED_IN_REGION.

Ran locally: the whole events-geojson int spec (30/30), the openapi-custom-endpoints unit spec, tsc for src/ and for the tests, ESLint and Prettier on the touched files.

No widget change is needed. Once this deploys, the preview feed parses again.

🤖 Generated with Claude Code

A live-preview request lifts the published-only access clause, so the
geojson feed carries drafts. Payload skips `required` on a draft save, so
a never-published draft can have no region, and the Atlas widget parses
every feature's `region` as an object: one null fails the whole feed and
the preview shows the error screen. Production holds two such drafts
(events 1932 and 2002), which broke every Region and Event live preview.

The feed now ANDs `region exists` onto every read, alongside the
finished-events filter. An event with no region has no place on the map
and no webPath, so nothing a consumer could render is lost.

Fixes SAHAJATLAS-WEB-2

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@railway-app

railway-app Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the SahajCloud-pr-1167 environment in sahajcloud

Service Status Web Updated
SahajCloud ✅ Success (View Logs) Web Nov 16, 2026 at 6:05 pm UTC
1 service not affected by this PR
  • mailpit

A live-preview token lifts the published-only access clause, which put
every unpublished draft on every previewed map. The feed now requires
`_status: published` for every caller. The previewed document never needed
the feed: the widget renders it, and frames its map marker, from its own
`draft=true` read.

The `region exists` clause stays. Publishing enforces `required`, but
deleting a region nulls `events.region_id` (`ON DELETE SET NULL`), and a
published event with no region would fail the widget's parse for every
visitor, not only in preview.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Ardnived Ardnived changed the title fix(events): keep region-less drafts out of the geojson feed fix(events): serve only published, placed events in the geojson feed Nov 16, 2026
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1167 November 16, 2026 16:39 Destroyed
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 16, 2026
@sydevs-bot

sydevs-bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🤖 no session running

recent dispatches
  • 17:54Z address-review · attempt 1 · session · done
  • 17:54Z address-review · attempt 1 · session
  • 17:00Z review-pr · attempt 1 · session · done
  • 17:00Z review-pr · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot moved this from Awaiting to Working in SYDevelopers Technical Roadmap Nov 16, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

The diff is the size of its problem: two clauses, a doc line, three cases. Both are correct and neither touches an ordinary client — the access layer already applies _status: published there, so PUBLISHED bites only on a preview request, and region is a single required relationship, so exists is region_id IS NOT NULL.

One question about the approach. The leak lives in createAccessConfig (plugins/access/accessConfigs.ts:184), which lifts the published-only clause for a live-preview request on every drafts collection. Closing it per feed leaves that lift open everywhere else. The widget only needs a draft by id, so narrowing the branch would fix the class and delete PUBLISHED from this diff.

Findings

  • should-fix — the clause is re-closed at one door while the access-layer lift stays collection-wide — geojson.ts:60.
  • consider — draft: 'true' in the new test does nothing — events-geojson.int.spec.ts:329.

What was checked

Read whole: geojson.ts, lifecycle/finished.ts, accessConfigs.ts, previewSecret.ts, Events.ts.

Ladder, on the two new constants: notFinishedWhere already owns the sibling clause, I checked whether they belong beside it. The only other events read that ANDs it (atlas/sitemap/resolve.ts:93) already filters region in <ids> and carries no preview token — so no. The file's four existing helpers each have one caller and a stated why.

Consumer side, SahajAtlasWeb: AgnosticFeedEventSchema (types/event.ts:149) still requires region. live-preview/request.ts attaches the token and draft=true to every request, which is how /api/events (the titles sliver, fetch.ts:264) still reads drafts. live-preview/populate.ts refuses any endpoint that is not <collection>/<id>, so the claim that the previewed document comes from its own read holds.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread tests/int/events-geojson.int.spec.ts Resolved
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 16, 2026
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 16, 2026
@Ardnived

Copy link
Copy Markdown
Contributor Author

@sydevs-bot address

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 16, 2026
@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 16, 2026
The handler forwards no `draft`, so the parameter reads as dead and the
next reader deletes it. It is there because the widget's live-preview
decorator sets it on every request, which is the shape the cases
reproduce — the fix had to land in the read's `where` for that reason.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjY7r47DsEKBeR3dvku
@sydevs-bot

Copy link
Copy Markdown
Contributor

Both review threads answered. Merged origin/main in cleanly first.

Lean gate green. events-geojson.int.spec.ts 30/30.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 16, 2026
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1167 November 16, 2026 18:02 Destroyed
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 16, 2026
@sydevs-bot

Copy link
Copy Markdown
Contributor

I could not apply the relay here, so this is the step left for you.

  • apply the relay — GitHub said: claude/relay-1167-0df323f does not exist

🤖 sydevs dispatcher

@sydevs-bot
sydevs-bot enabled auto-merge November 16, 2026 18:20
@Ardnived
Ardnived disabled auto-merge November 16, 2026 22:46
@Ardnived
Ardnived merged commit 2de5d51 into main Nov 16, 2026
9 of 10 checks passed
@Ardnived
Ardnived deleted the fix/geojson-feed-region-less-drafts branch November 16, 2026 22:46

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-1167 — 0df323f1 Deployed Nov 16, 2026 by railway-app[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants