Skip to content

fix(map): handle missing MapTiler key - #192

Merged
AnayDhawan merged 1 commit into
StudentSuite:mainfrom
AyobamiH:fix/147-missing-maptiler-key
Sep 5, 2026
Merged

fix(map): handle missing MapTiler key#192
AnayDhawan merged 1 commit into
StudentSuite:mainfrom
AyobamiH:fix/147-missing-maptiler-key

Conversation

@AyobamiH

@AyobamiH AyobamiH commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Problem

When NEXT_PUBLIC_MAPTILER_KEY is missing or blank, MapView still mounts Leaflet with a tile URL ending in ?key=. MapTiler rejects each tile request, but no React error is thrown. The existing error boundary therefore never replaces the gray, unusable map.

Closes #147.

Reproduction

On current main, with NEXT_PUBLIC_MAPTILER_KEY unset:

  • /map responds successfully.
  • The client constructs a MapTiler URL ending in ?key=.
  • The tile endpoint responds with HTTP 403.
  • No actionable state is shown to the user.

Changes

  • Trim and validate the MapTiler key before mounting Leaflet.
  • Render an accessible Basemap unavailable state when the key is missing or blank.
  • Link the fallback to the self-hosting setup guide.
  • Emit the configuration warning once in non-production environments.
  • Document the visible symptom and recovery steps in SELF-HOSTING.md.
  • Add a component regression test covering the fallback, setup link, and warning.

Why this layer

This is handled in MapView, not MapErrorBoundary, because failed HTTP tile requests do not throw a React rendering error. Stopping the map from mounting without its required configuration prevents the failing requests at their source.

Verification

  • npm run lint
  • npx tsc --noEmit
  • npm run test:unit: 16 files and 129 tests passed
  • env -u NEXT_PUBLIC_MAPTILER_KEY npx next build: production build passed with 489 generated pages

@vercel

vercel Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

@AyobamiH is attempting to deploy a commit to the studentsuite Team on Vercel.

A member of the Team first needs to authorize it.

@AnayDhawan

Copy link
Copy Markdown
Member

Thanks for the PR. If StudyMap has been useful, a star on the repo helps more students find it. Appreciated either way.

@AnayDhawan
AnayDhawan merged commit f38dc97 into StudentSuite:main Sep 5, 2026
4 of 5 checks passed
@AnayDhawan

Copy link
Copy Markdown
Member

Merged, thanks. Nice work: the role="status" treatment, the dev-only warn with the module-level dedupe flag, and shipping a test alongside the fix all made this easy to review. The SELF-HOSTING.md note was a good call too.

Closes #147.

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.

bug: missing NEXT_PUBLIC_MAPTILER_KEY silently renders a gray, dead map

2 participants