Skip to content

osm slab hydration: never fail silently on missing config - #118

Merged
AdaWorldAPI merged 1 commit into
mainfrom
claude/q2-osm-map-reencoding-56p5e2
Aug 12, 2026
Merged

osm slab hydration: never fail silently on missing config#118
AdaWorldAPI merged 1 commit into
mainfrom
claude/q2-osm-map-reencoding-56p5e2

Conversation

@AdaWorldAPI

@AdaWorldAPI AdaWorldAPI commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Diagnosing why the live maps.oga.red deploy 503s on /api/osm/geometry/tile/* turned up a real gap, found by comparing against MedCare-rs's bake_hydrate.rs/bake_s3.rs — the same "boot-time S3 hydration onto a persistent volume" shape, already hardened after its own documented incident ("the silent-empty deploy earlier in this arc").

The bug

let bucket = std::env::var("AWS_S3_BUCKET_NAME").ok()?;
let vol = std::env::var("OSM_SLAB_CACHE_DIR").or_else(|_| std::env::var("RAILWAY_VOL")).ok()?;

Zero logging before either ?, and main.rs's caller has no else branch on None. A deploy missing AWS_S3_BUCKET_NAME or RAILWAY_VOL produces literally nothing about OSM slab hydration in the boot log — not a warning, not an error. This is why searching Railway's deploy logs for "osm slab" came up empty: there was structurally nothing to find on this path.

The fix, ported from a working sibling

MedCare-rs's S3Config::from_env always logs, even in the nothing-configured case, and names the exact vars needed:

"no source configured — ... neither S3 (AWS_ENDPOINT_URL / AWS_S3_BUCKET_NAME /
 AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY) nor GITHUB_TOKEN is set"

It also treats an empty variable value the same as absent (.filter(|v| !v.is_empty())) — a Railway variable can exist as a row with a blank value, and that must fail the same way as not existing, rather than attempting a real S3 call with an empty bucket name and failing later, differently, and less legibly.

Ported both properties, scoped strictly to logging — the fetch/checksum/cache logic is unchanged:

  • env_var_nonempty() — empty treated as absent.
  • missing_inputs() — pure function naming every absent piece, not just the first hit; testable without touching real env vars (ensure_slab_local is the only caller that reads std::env::var directly).
  • ensure_slab_local() now tracing::warn!s and names the missing variable(s) before returning None for a missing-config reason.

Tests

Two new, both on the pure missing_inputs() core: names every absent variable (the actual regression this fixes — a version that only checks the first var and returns early would fail this), and stays empty (anti-vacuity) when both inputs are present.

97 passed, 0 failed (95 prior from #117 + 2 new).

What this doesn't fix

This makes the failure observable, not necessarily resolved — I still don't know which of the required Railway variables is actually missing/empty on the live deploy. The next deploy's boot log will say so explicitly; from there it's a one-line env var fix on Railway's side, not a code change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NMeiLmtDKhomJNSo2ecbJw


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved startup handling when slab hydration configuration is missing or blank.
    • Missing configuration details are now reported clearly, while hydration is skipped safely.
    • Prevented hydration attempts when required storage or cache settings are unavailable.
  • Tests

    • Added coverage for missing configuration inputs and fully configured hydration scenarios.

The reason the deploy log had nothing to grep for: ensure_slab_local()
returned None via a bare `.ok()?` on AWS_S3_BUCKET_NAME and
OSM_SLAB_CACHE_DIR/RAILWAY_VOL, with zero logging on that path, and
main.rs's caller has no `else` branch on None. A deploy missing either
var produces LITERALLY NOTHING about OSM slab hydration in the boot
log — not a warning, not an error. Searching for "osm slab" was never
going to find anything on that path, which is the whole reason today's
diagnosis stalled.

Found by comparing against medcare-rs's bake_hydrate.rs / bake_s3.rs —
the same boot-time S3-hydration-onto-a-volume shape, hardened after its
own documented incident ("the silent-empty deploy earlier in this
arc"). It always logs, even in the nothing-configured case, and names
the exact variables needed:

    "no source configured — ... neither S3 (AWS_ENDPOINT_URL /
     AWS_S3_BUCKET_NAME / AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY)
     nor GITHUB_TOKEN is set"

It also treats an EMPTY variable value the same as absent
(`.filter(|v| !v.is_empty())` in S3Config::from_env) — a Railway
variable can exist as a row with a blank value, and that must fail the
same way as not existing, not attempt a real S3 call with an empty
bucket name and fail later, differently, and less legibly.

Ported both properties into osm_slab_hydrate.rs, scoped to logging
only — the actual hydration logic (fetch, checksum-verify, cache) is
unchanged:

- env_var_nonempty(): empty treated as absent, matching bake_s3's rule.
- missing_inputs(): pure function naming every absent piece (not just
  the first one hit) — testable without touching real env vars, since
  ensure_slab_local() is the only caller that reads std::env::var.
- ensure_slab_local() now WARNs and names the missing variable(s)
  before returning None for a missing-config reason.

Two new tests, both on the pure missing_inputs() core: names every
absent variable (not just the first — the regression this fix is for),
and stays empty (anti-vacuity) when both inputs are present.

97 passed, 0 failed (95 prior + 2 new).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NMeiLmtDKhomJNSo2ecbJw
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4475f96f-1bd0-480e-842e-944feb0ba79b

📥 Commits

Reviewing files that changed from the base of the PR and between a644490 and b5cf9a8.

📒 Files selected for processing (2)
  • crates/cockpit-server/src/main.rs
  • crates/cockpit-server/src/osm_slab_hydrate.rs

📝 Walkthrough

Walkthrough

The slab hydration configuration now treats missing and blank environment values as absent, reports all missing required inputs, and exits before S3 setup. Startup documentation describes the logging behavior, and regression tests cover incomplete and complete configurations.

Changes

Slab hydration configuration

Layer / File(s) Summary
Configuration resolution and validation
crates/cockpit-server/src/osm_slab_hydrate.rs
The module documents missing-configuration behavior. New helpers trim environment values and report every missing bucket or cache-volume input. Tests cover missing and complete inputs.
Hydration startup behavior
crates/cockpit-server/src/osm_slab_hydrate.rs, crates/cockpit-server/src/main.rs
Hydration uses non-empty configuration values, preserves cache-directory override precedence, logs missing variables, and returns before S3 setup. Startup documentation describes the silent caller behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • AdaWorldAPI/q2#112: Introduced the S3 slab hydration configuration and startup call site refined by this change.

Suggested reviewers: claude

Poem

A rabbit checks the bucket twice,
And trims the blanks from config’s lines.
Missing names are logged in rows,
No S3 stream begins or flows.
The slab wakes when settings shine.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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

Comment @coderabbitai help to get the list of available commands.

@cursor

cursor Bot commented Aug 12, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_6287bd9a-69a8-4924-b152-31c2bd1a4717)

@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review August 12, 2026 07:12
@AdaWorldAPI
AdaWorldAPI merged commit e56324c into main Aug 12, 2026
4 of 5 checks passed
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