Skip to content

Apply a stop consolidation file on static import - #1776

Draft
aaronbrethorst wants to merge 1 commit into
ab/stop-consolidation-storefrom
ab/stop-consolidation-load
Draft

aaronbrethorst wants to merge 1 commit into
ab/stop-consolidation-storefrom
ab/stop-consolidation-load

Conversation

@aaronbrethorst

@aaronbrethorst aaronbrethorst commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Part of #1977

Draft. Stacked on #1775. Draft until multi-feed phases B and C land.

What it does

When Config.StopConsolidationURL is set, the static import reads the file (from a URL or a local path) and applies it:

  • Which stops a token names: the file's stop IDs use the feed's first agency in agency.txt, the agency Java names every stop in a feed after.
  • Warnings: each problem Validate finds is logged as a warning with its kind and line. None of them stops the import.
  • Failures: a file that can't be read, is over 1 MB, or has a malformed stop ID fails the import, as it fails Java's bundle build. The previous database keeps serving.
  • Import hash: the file's hash is part of it, so changing only the file causes a re-import, and an unchanged feed and file skip parsing as before.

The config option itself comes in #1773.

Root cause

Connects the parser, validator and Apply (#1771, #1772, #1774) to the import step in #1775.

Testing

  • Test failing on main before this change: n/a (new feature).

  • Manual check: RABA with 25_5008 25_5027 and 25_gone 25_3022, compared with the same feed and no file:

    Request Without file With file
    schedule-for-stop/25_5008 (2025-06-02) 25 stop times 50 stop times
    schedule-for-stop/25_5027 200 404
    stop/25_3022 200 404
    trip-details/25_ef279c99… 25 stops 24 stops, skipping 3022
    • The missing_canonical warning for line 3 is logged.
    • After a restart, the unchanged feed and file skip the import.
  • TestStopConsolidation_* covers:

    • applied on import
    • a changed file triggers a re-import
    • fetching over HTTP, including a 404
    • a malformed file
    • an oversized file
    • a feed with no agencies
  • make test and go vet (both tag sets) pass.

Checklist

  • This PR addresses one issue.
  • It is under ~200 changed lines, or the description says why it can't be split.
  • This PR is not a bug fix, or the new or changed test fails on main and passes on this branch.
  • Each commit is one logical change with a clear message.
  • I did not hand-edit sqlc-generated files under gtfsdb/ (db.go, models.go, query.sql.go) or testdata/openapi.yml (synced from upstream).
  • This PR changes no handler, or handlers pass r.Context() to DB/service calls, not context.Background().
  • The response comparison above is filled in, or this PR doesn't change a Java-served response.
  • This PR adds no endpoint, or each new endpoint matches testdata/openapi.yml, has an issue open on OneBusAway/sdk-config, or is outside the SDK and the description says why.
  • I read every line of this diff and can explain it if asked.

Notes for reviewers

  • Single-feed caveat: with one feed loaded, a line naming another feed's stops does nothing. The exception is a line that absorbs this feed's stop into a stop from an unloaded feed: that stop is dropped, as Java would drop it. The warnings name each such line.
  • Unreachable URL: the consolidation file is fetched before the "already imported?" check, so an unreachable URL fails startup even when the database is current. The feed itself is handled the same way.

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

The description follows the PR template.

@github-actions

Copy link
Copy Markdown

Performance Smoke Test Results

Status: PASSED

Metric Value
p(95) latency 1.5 ms
Error rate 0.00%
Total requests 327
Req/sec 10.7

Smoke test config: 5 VUs x 30s. Thresholds: p(95) < 300ms, error rate < 1%.

Full results uploaded as workflow artifact: k6-smoke-summary.

@github-actions github-actions Bot added the follows-template The PR description follows the PR template label Nov 8, 2026
When Config.StopConsolidationURL is set, the static import reads the
file, from a URL or a local path, and applies it:

- The file's stop IDs use the feed's first agency in agency.txt, the
  agency Java names every stop in a feed after.
- Each problem Validate finds is logged as a warning, with its kind
  and line. None stops the import, because Java loads such files.
- A file that can't be read, or has a malformed stop ID, fails the
  import, as it fails Java's bundle build. The database keeps serving
  the previous import.
- The file's hash is part of the import hash, so changing the file
  alone causes a re-import, and an unchanged feed and file skip
  parsing as before.

Absorbed stops without coordinates are not in the loaded set, because
maglev never stores them.
@aaronbrethorst
aaronbrethorst force-pushed the ab/stop-consolidation-load branch from 4dee8da to ae96840 Compare November 8, 2026 17:58
@sonarqubecloud

sonarqubecloud Bot commented Nov 8, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

Performance Smoke Test Results

Status: PASSED

Metric Value
p(95) latency 2.3 ms
Error rate 0.00%
Total requests 331
Req/sec 10.8

Smoke test config: 5 VUs x 30s. Thresholds: p(95) < 300ms, error rate < 1%.

Full results uploaded as workflow artifact: k6-smoke-summary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

follows-template The PR description follows the PR template

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant