Repository navigation
[flags] encryptFlagValues returns an empty value when the public key of Vercel does not load - #604
Merged
luismeyer merged 2 commits intoNov 17, 2026
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…key of Vercel does not load Without a FLAGS_SECRET, a key host which is down, or a request which timed out, failed the build or the render of each page which encrypts flag values. The values are only for the Vercel Toolbar, so encryptFlagValues now warns and returns an empty string, and FlagValues renders nothing for it. Errors of the configuration still throw. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The warning said "Could not encrypt the flag values", which reads as if they are written to the page in plaintext. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
luismeyer
force-pushed
the
luismeyer/encrypt-flag-values-degrade
branch
from
November 17, 2026 12:33
4177469 to
382cc08
Compare
luismeyer
changed the base branch from
luismeyer/precompute-deployment-key
to
luismeyer/flag-values-platform-encryption
November 17, 2026 12:33
luismeyer
merged commit Nov 17, 2026
a24025d
into
luismeyer/flag-values-platform-encryption
20 checks passed
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What / why
This is a behavior change. Without a
FLAGS_SECRET,encryptFlagValuesloads the public key of Vercel fromhttps://keys.vercel-flags.com/.well-known/jwks.json. When the key did not load, it threw, so a key host which is down failed the build of each prerendered page and the render of each dynamic page which calls it. The flag values are only for the Vercel Toolbar, so the page must not depend on the key host.With this change,
encryptFlagValueswarns and returns an empty string when the key does not load, andFlagValuesofflags/reactrenders nothing for an empty string.lib/flag-values-platform.ts:encryptFlagValuesForPlatformcatches only theKeySetErrorof the key cache (new on this base, exported,@internal; the cache threw a plainErrorbefore) aroundpublicKey.get(). That covers each way the key does not load: a timeout or a network error after the three attempts, a status which is not ok, a key set which is not valid or has no key for ECDH-ES, and the cooldown of 30 seconds after a failure.flags: The flag values for the Vercel Toolbar are left out of the page. <cause>, at most one time in 30 seconds per process (warnWithCooldown).createHandleof SvelteKit loggedflags: Could not encrypt the flag values for the Vercel Toolbar. <cause>before, which reads as if the values are written to the page in plaintext. Both now use one helper,warnFlagValuesLeftOut, so the SvelteKit message changes too.Promise<string>.flags/react:FlagValuesreturnsnullfor''. Ascripttag with""would make the Toolbar send an empty string to the decrypt API.createHandlealready rendered the page without the flag values. It now also returns the HTML unchanged for the empty string, so it never injects ascripttag with"". Its catch stays for the other failures without a secret (no project ID). The warning is the same as before.encryptFlagValuesofflags/sveltekitreturns the empty string too.What still throws
flags: Missing FLAGS_SECRET or a project ID ...), and a project ID which is too long. In Next.js the app callsencryptFlagValuesitself, so these are for the developer. They are checked before the key is loaded.digest, e.g.DYNAMIC_SERVER_USAGEof Next.js). The key cache does not wrap it, and it is not caught here.Evidence
vercel-docs-geistdocs. vercel/front#98090 bumped the snapshot which added the retries after it.vercel-docs,vercel-marketing): 100 runtime errorsflags: Could not load the public key for the flag values ...(95 invercel-marketingon Nov 16, 5 invercel-docson Nov 17), and 5,403 build-log lines with this error across 63 deployments. It was not checked how many of these builds failed.Limits
scripttag withdata-flag-valuesitself, and not withFlagValues, now renders""in this case. The docs say to leave the tag out for an empty value.encryptFlagValuesno longer gets it. The stack is not released, so this affects only the snapshots.api-reference/core/core.mdxandreact.mdx.Tests
packages/flags:pnpm test(20 files, 327 tests passed),pnpm type-check,pnpm checkandpnpm buildare ok.node scripts/validate-packages.mjsis ok.New and changed tests:
lib/flag-values-platform.test.ts: the key does not load (three timeouts, 404, 503, a key set with a private key, a key set without a key for ECDH-ES) resolves to''and warns one time per cooldown; it encrypts again when the key loads after the cooldown; no project ID still throws, without a request and without a warning; a secret which is not valid still throws and does not load the key. The test for an error with adigestis unchanged and still rejects with the same error.react/index.test.tsx:FlagValuesrenders the tag for values, for a token and for{}, and nothing for''.sveltekit/without-secret.test.ts: the existing test ofcreateHandlefor a key which does not load passes unchanged (same HTML, three requests, one warning, same text). Without the new guard it fails with<script ...>""</script>in the HTML. New:encryptFlagValuesofflags/sveltekitresolves to''.tests/next-static-build: the page now usesFlagValues. New case:next buildwith a key host which answers 503 exits with 0, the page is static, the HTML has nodata-flag-values, and the build output has the warning. Both cases pass.Note for
tests/next-static-build: inside an AI coding agent,next buildof Next.js 16.4.3 exits with 1 after the build, to print a notice that this version of Next.js has a known security vulnerability. This is so on the base branch too. Without the agent environment variables, as in CI, both cases pass.🤖 Generated with Claude Code