Skip to content

fix(build): the Mapbox download token must not fall back to the public one - #694

Merged
thinkclay merged 1 commit into
mainfrom
fix/mapbox-download-token
Sep 1, 2026
Merged

thinkclay merged 1 commit into
mainfrom
fix/mapbox-download-token

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

I broke both native builds and this is the fix.

Registering EXPO_PUBLIC_MAPBOX_TOKEN as an EAS environment variable (#686) did what it was meant to — the map token finally reaches a cloud build. It also populated RNMapboxMapsDownloadToken, which fell back to it:

RNMapboxMapsDownloadToken: process.env.MAPBOX_DOWNLOADS_TOKEN
                        || process.env.EXPO_PUBLIC_MAPBOX_TOKEN

Those are two different credentials for two different APIs:

MAPBOX_DOWNLOADS_TOKEN EXPO_PUBLIC_MAPBOX_TOKEN
Kind secret sk. public pk.
Scope DOWNLOADS:READ map rendering
Used by CocoaPods / Gradle, at build time the app, at runtime

Substituting one for the other does not degrade gracefully. Asked Mapbox directly:

token kind      pk.
scopes          0
DOWNLOADS:READ  NO
downloads API   HTTP 403

Both builds died in dependency resolution — iOS beabeb27 at Install pods, Android 7eff37b0 at Run gradlew — which is precisely where a 403 from the Mapbox downloads API lands.

The fallback was always wrong

It only looked harmless because EXPO_PUBLIC_MAPBOX_TOKEN never reached an EAS worker, so the expression evaluated to undefined and the 10.1.x SDK resolved unauthenticated.

Every successful build up to 11700 depended on that fallback not firing. Fixing #686 turned an absent download token into a wrong one — which is worse, because absent works and wrong 403s.

So: no fallback. undefined is the correct value when there is no secret token.

What this does not fix

#509 stands. Without a real sk. token, @rnmapbox/maps still cannot move past 10.1.x, and MAPBOX_DOWNLOADS_TOKEN is set in no env file and no EAS environment. Minting one is a step in the Mapbox account, and it is a credential — not something this repo should conjure.

ship-ios.sh already warns that MAPBOX_DOWNLOADS_TOKEN is missing. That warning was correct all along; it just described a latent problem rather than an active one.

Verified: expo config resolves 1.17.1 / 11701, prepush green.

🤖 Generated with Claude Code

…c one

I broke both native builds and this is the fix.

Registering EXPO_PUBLIC_MAPBOX_TOKEN as an EAS environment variable (#686) did
what it was supposed to — the map token finally reaches a cloud build. It also
populated RNMapboxMapsDownloadToken, which fell back to it:

  RNMapboxMapsDownloadToken: process.env.MAPBOX_DOWNLOADS_TOKEN
                             || process.env.EXPO_PUBLIC_MAPBOX_TOKEN

Those are two different credentials for two different APIs. MAPBOX_DOWNLOADS_
TOKEN is a secret `sk.` token with DOWNLOADS:READ, used by CocoaPods and Gradle
to fetch the Mapbox SDK at build time. EXPO_PUBLIC_MAPBOX_TOKEN is a public
`pk.` token used by the app at runtime to draw maps. Substituting one for the
other does not degrade gracefully:

  token kind      pk.
  scopes          0
  DOWNLOADS:READ  NO
  downloads API   HTTP 403

Both builds died in dependency resolution — iOS beabeb27 at Install pods,
Android 7eff37b0 at Run gradlew — which is exactly where a 403 from the Mapbox
downloads API lands.

The fallback was always wrong. It looked harmless only because
EXPO_PUBLIC_MAPBOX_TOKEN never reached an EAS worker, so the expression
evaluated to undefined and the 10.1.x SDK resolved unauthenticated. Every
successful build up to 11700 was relying on the fallback NOT firing. Fixing
#686 turned an absent download token into a wrong one.

So: no fallback. Undefined is the correct value when there is no secret token.

This restores the build; it does not fix #509. Without a real sk. token
@rnmapbox/maps still cannot move past 10.1.x, and MAPBOX_DOWNLOADS_TOKEN is
still set in no env file and no EAS environment. That needs a token minted in
the Mapbox account with DOWNLOADS:READ — a human step, and a credential, so it
is not something this repo should try to conjure.
@thinkclay
thinkclay merged commit 8f9d6bf into main Sep 1, 2026
3 checks passed
@thinkclay
thinkclay deleted the fix/mapbox-download-token branch September 1, 2026 21:10
thinkclay added a commit that referenced this pull request Sep 15, 2026
…rew, and iPads got two layouts at once (#769)

Closes #373 — the iPad audit that was filed as low priority and turned out to
hold a P0.

The native map has never rendered. mapboxStyleConfig.ts set the light style
to mapbox://styles/mapbox/standard in fe152b1 (2026-03-13) and the dark
style to a Scaffald style that imports it. Both need Mapbox Maps SDK v11;
the app bundles MapboxMaps 10.19.5 (@rnmapbox/maps 10.1.45). On v10 the
style request answers 200 — the token is fine, which is why #686/#694 could
not have caught this — and the SDK paints nothing: a black map with markers
floating on it. git tag --contains fe152b1 is every tag from app-v1.0.1
through app-v1.17.1, the build on TestFlight now. Proven by swapping in
streets-v12 alone and watching the same screen render. Native now reads
NATIVE_MAP_STYLE_CONFIG (streets-v12 / dark-v11); web keeps Standard, which
mapbox-gl JS v3 draws. The SDK v11 move that lets native have Standard too
is #765.

Every Office table threw "Text strings must be rendered within a <Text>
component" on native. columnsFromTanStack() hands flexRender()'s result to
@scaffald/ui's Table, which drops render() output straight into a <View>;
flexRender returns the raw value for any column without a custom cell. Web
tolerates a bare string there, native does not. Primitives now get a <Text>.

A 1032pt iPad Pro rendered the drawer's sidebar layout (width < 1024) and
the map screen's phone layout (isSmallScreen = width <= 800 || isNativeMobile)
at the same time, so the floating Map/List bar sat clipped over a
desktop-width map. Phones are under 800 on every platform, so the native
override only ever changed the answer for tablets, and changed it the wrong
way. Width alone now.

ui-sweep.mjs takes AUDIT_DEVICE (iphone | ipad-portrait | ipad-landscape |
android) so #373's viewports and #372's web half are one command each; its
login no longer clicks a terms checkbox the form has not had since #342; and
it dismisses the dev error overlay the #681 hydration mismatch paints over
every protected route at these widths. Three sweeps ran clean on --no-dev:
121 captures, 0 errors, no tablet-only layout break on web (768 gets the
phone layout, 1024 gets the sidebar).

Verified on the iPad Pro 13" simulator with an SDK 56 dev client built from
this tree: map renders, Office loads without the error, sidebar + desktop map
layout. Findings that need a decision rather than a fix are filed: #764
(native shows the web cookie banner), #765 (SDK v11). Two gotchas hit on the
way and worth knowing: Metro OOMs when a native lazy route bundles during a
web SSR sweep (#680) — keep the simulator idle while sweeping — and the
preview launcher reads the main checkout's .claude/launch.json, not the
worktree's.

scf-core:typecheck clean; biome reports only pre-existing hits on untouched
lines.
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.

1 participant