Skip to content

feat: Use URL-safe base64 for auto-generated message keys of useExtracted#2330

Merged
amannn merged 5 commits into
amannn:mainfrom
spokodev:fix/use-extracted-url-safe-base64
May 28, 2026
Merged

feat: Use URL-safe base64 for auto-generated message keys of useExtracted#2330
amannn merged 5 commits into
amannn:mainfrom
spokodev:fix/use-extracted-url-safe-base64

Conversation

@spokodev

@spokodev spokodev commented May 18, 2026

Copy link
Copy Markdown
Contributor

Auto-generated useExtracted message keys now use URL-safe base64 (-_) instead of standard base64 (+/).

Standard base64 can produce keys starting with / (e.g. /qP5M+). When those keys appear in serialized page data, Googlebot treats /-prefixed values as relative URL paths and reports 404s in Search Console (#2250).

The hash input is unchanged (still SHA-512, first 6 characters). Only the alphabet differs—keys no longer contain URL-significant + or / characters.

 // messages/en.json (example)
 {
-  "+YJVTi": "Hey!",
+  "-YJVTi": "Hey!",
   "NhX4DJ": "Hello"
 }
 // messages/en.po (example)
 #: src/components/Greeting.tsx
-msgid "+YJVTi"
+msgid "-YJVTi"
 msgstr "Hey!"

Breaking change

Keys for messages whose hash previously encoded + or / in the first 6 characters get a new ID (e.g. +YJVTi-YJVTi, nm/7yQnm_7yQ). Most keys are unaffected.

To migrate, in all locale catalogs, search & replace message keys only (JSON keys / msgid values—not msgstr content):

  • +-
  • /_

Only keys that previously contained + or / need updating, most keys are unchanged.


Fixes #2250

Standard base64 uses `+/` which produces keys like `/qP5M+`. When these
keys appear in serialised page data, Googlebot treats the `/`-prefixed
ones as relative URL paths and reports them as 404s in Search Console.
The reporter in amannn#2250 observed ~56 of 3361 keys starting with `/`.

Switch the encoder to URL_SAFE_NO_PAD which uses `-_` instead. The hash
input is unchanged, so keys deriving from the same message remain
stable shape (still 6 chars, still SHA-512 prefix), but no longer
collide with URL-significant characters.

useExtracted is still flagged experimental, so the maintainer noted on
amannn#2250 that the key hash is open to change. Auto-extracted keys are
regenerated from the canonical messages on every build, so consumers
who haven't pinned key strings will see them refresh on next build.

Fixture snapshots regenerated; all 28 cargo tests pass.

Fixes amannn#2250
@vercel

vercel Bot commented May 18, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the next-intl Team on Vercel.

A member of the Team first needs to authorize it.

@amannn

amannn commented May 19, 2026

Copy link
Copy Markdown
Owner

Hey @spokodev, thanks for opening this PR!

Yes, I think this is the right approach and that we should go with this.

Let me see when we can release this, I'll get back to you …

@spokodev

Copy link
Copy Markdown
Contributor Author

Thanks for the quick look, @amannn — appreciated. Happy to rebase if anything drifts before the release window. Flipping out of draft.

@spokodev spokodev marked this pull request as ready for review May 23, 2026 11:58
@vercel

vercel Bot commented May 28, 2026

Copy link
Copy Markdown

Deployment failed with the following error:

The provided GitHub repository does not contain the requested branch or commit reference. Please ensure the repository is not empty.

@amannn amannn force-pushed the fix/use-extracted-url-safe-base64 branch from 78fe5d0 to 7f0bc19 Compare May 28, 2026 13:24
@vercel

vercel Bot commented May 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
next-intl-docs Ready Ready Preview, Comment May 28, 2026 1:30pm
next-intl-example-app-router Ready Ready Preview, Comment May 28, 2026 1:30pm
next-intl-example-app-router-without-i18n-routing Ready Ready Preview, Comment May 28, 2026 1:30pm

Request Review

@amannn amannn changed the title fix(use-extracted): use URL-safe base64 for auto-generated message keys feat: Use URL-safe base64 for auto-generated message keys of useExtracted May 28, 2026
@amannn amannn force-pushed the fix/use-extracted-url-safe-base64 branch from 7f0bc19 to 78fe5d0 Compare May 28, 2026 14:08
@amannn amannn merged commit a003d3a into amannn:main May 28, 2026
6 checks passed
spokodev added a commit to spokodev/spoko-studio that referenced this pull request Jun 4, 2026
Activates /upstream page in header nav (gate publishedCount >= 3 now satisfied):

- amannn/next-intl#2330 — URL-safe base64 for auto-generated message keys
- raycast/extensions#28425 — Hong Kong and Macau ISO codes for own flags
- firefox-devtools/profiler#6085 — clip flame-graph filter bar overflow

EN + UK summaries hand-authored; six other locales seeded as EN stubs
pending pnpm translate polish.
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.

useExtracted auto-generated message keys starting with / cause Google crawler 404 errors

2 participants