Skip to content

Accept VARLOCK_* aliases for _VARLOCK_* config vars (AWS Lambda) - #1295

Merged
theoephraim merged 3 commits into
mainfrom
varlock-config-var-aliases
Nov 12, 2026
Merged

theoephraim merged 3 commits into
mainfrom
varlock-config-var-aliases

Conversation

@theoephraim

@theoephraim theoephraim commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

AWS Lambda rejects env var names that start with _, so _VARLOCK_ENV_KEY (needed at runtime to decrypt an env frozen with freezeIntoBundle) can't be set there. Reported on Discord; the workaround was copying VARLOCK_ENV_KEY onto _VARLOCK_ENV_KEY at the top of the handler.

Each user-settable _VARLOCK_* config var can now also be set without the leading underscore (VARLOCK_ENV_KEY, VARLOCK_USE_FROZEN_ENV, ...). The underscore form wins when both are set.

  • runtime/lib/config-env-aliases.ts copies aliases onto the _VARLOCK_* names when unset. Applied at varlock/env module load (before the pre-injection snapshot), initVarlockRuntime, auto-load, and CLI startup, so existing readers are unchanged.
  • Explicit name list (kept in sync with reserved-vars.ts by a test), so builtins like VARLOCK_ENV are never aliased. The alias names are reserved like _VARLOCK_* keys (isVarlockReservedKey), so a schema item named VARLOCK_ENV_KEY is never serialized or typed.
  • initVarlockRuntime reads the key with alias fallback directly, so decryption works where process.env is read-only and the copy no-ops. Added the already-documented _VARLOCK_ALLOW_PLAINTEXT_FROZEN_ENV to reserved-vars.ts.
  • Tests: unit tests for the helper and for decrypting with only VARLOCK_ENV_KEY, edge-evaluable init-bundle case, smoke tests for frozen file / --out - payload boot with only underscore-free names. The Next standalone freezeIntoBundle framework scenario now boots with VARLOCK_ENV_KEY.
  • Docs: reserved variables reference, encrypted deployments guide, Next.js freeze section, and a note that the frozen --out - env var payload does not fit Lambda (__VARLOCK_ENV name, 4 KB env limit).

AWS Lambda rejects env var names starting with an underscore, so
_VARLOCK_ENV_KEY (needed at runtime for an encrypted frozen env) cannot
be set there. Each _VARLOCK_* config var can now also be set without the
leading underscore; the underscore form wins when both are set.
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

bumpy-frog

The changes in this PR will be included in the next version bump.

patch Patch releases

  • @varlock/native-helper-darwin 1.24.0 → 1.24.1
  • @varlock/native-helper-linux-arm64 1.24.0 → 1.24.1
  • @varlock/native-helper-linux-x64 1.24.0 → 1.24.1
  • @varlock/native-helper-win32-x64 1.24.0 → 1.24.1
  • @varlock/nextjs-integration 2.0.0 → 2.0.1
  • varlock 1.24.0 → 1.24.1

Bump files in this PR

Click here if you want to add another bump file to this PR


This comment is maintained by bumpy.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

📦 Bundle size

⚠️ grows the bundle by 17.1 KB (+0.3%)

Metric main This PR Δ
Total dist 5187.5 KB 5204.5 KB +17.1 KB (+0.3%)
JS 1979.2 KB 1985.6 KB +6.4 KB (+0.3%)
Sourcemaps 3067.6 KB 3075.9 KB +8.2 KB (+0.3%)
Type defs 140.6 KB 143.1 KB +2.4 KB (+1.7%)
Other 0.0 KB 0.0 KB —

dist/ only; native binaries are versioned separately and not counted here.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
varlock-website 72ca471 Commit Preview URL

Branch Preview URL
Nov 12 2026, 06:23 PM

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The aliases need the same reserved-key protection as their canonical names, and encrypted runtime initialization still fails with alias-only keys on read-only environments.

Reviewed changes: Reviewed underscore-free configuration aliases across CLI startup, runtime initialization, auto-load, and frozen deployments.

  • Alias normalization: Adds an explicit configuration-variable list and copies aliases before existing readers and environment snapshots run.
  • Frozen deployment coverage: Adds helper, decryption, edge-bundle, and smoke tests, and switches the Next standalone scenario to VARLOCK_ENV_KEY.
  • Registry and documentation: Registers the plaintext frozen-build opt-out and documents aliases and precedence in deployment and configuration references.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.1-sol | 𝕏

Comment thread packages/varlock/src/runtime/init.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes: Reviewed the reserved-alias and read-only environment fixes since the prior review, plus the Lambda deployment clarification.

  • Reserved configuration aliases across serialization, override provenance, and generated types while preserving computed builtins; added ambient-key regression coverage.
  • Added read-time key fallback so encrypted runtime initialization accepts VARLOCK_ENV_KEY on immutable environments; verified the frozen-environment edge regression.
  • Clarified deployment constraints and documented that alias names are reserved schema keys.

The build succeeded and all 264 runtime and reserved-key tests passed.

Pullfrog  | View workflow run | Using gpt-6.1-sol | 𝕏

@pkg-pr-new

pkg-pr-new Bot commented Nov 12, 2026

Copy link
Copy Markdown

Open in StackBlitz

varlock

npm i https://pkg.pr.new/varlock@1295

@varlock/astro-integration

npm i https://pkg.pr.new/@varlock/astro-integration@1295

@varlock/cloudflare-integration

npm i https://pkg.pr.new/@varlock/cloudflare-integration@1295

@varlock/nextjs-integration

npm i https://pkg.pr.new/@varlock/nextjs-integration@1295

@varlock/nuxt-integration

npm i https://pkg.pr.new/@varlock/nuxt-integration@1295

@varlock/vite-integration

npm i https://pkg.pr.new/@varlock/vite-integration@1295

@varlock/native-helper-darwin

npm i https://pkg.pr.new/@varlock/native-helper-darwin@1295

@varlock/native-helper-linux-arm64

npm i https://pkg.pr.new/@varlock/native-helper-linux-arm64@1295

@varlock/native-helper-linux-x64

npm i https://pkg.pr.new/@varlock/native-helper-linux-x64@1295

@varlock/native-helper-win32-x64

npm i https://pkg.pr.new/@varlock/native-helper-win32-x64@1295

@varlock/1password-plugin

npm i https://pkg.pr.new/@varlock/1password-plugin@1295

@varlock/bitwarden-plugin

npm i https://pkg.pr.new/@varlock/bitwarden-plugin@1295

@varlock/keepass-plugin

npm i https://pkg.pr.new/@varlock/keepass-plugin@1295

@varlock/pass-plugin

npm i https://pkg.pr.new/@varlock/pass-plugin@1295

@varlock/proton-pass-plugin

npm i https://pkg.pr.new/@varlock/proton-pass-plugin@1295

commit: 72ca471

@theoephraim
theoephraim merged commit 704e18e into main Nov 12, 2026
35 checks passed
theoephraim added a commit that referenced this pull request Nov 13, 2026
* Fix release PR smoke and framework test failures

Keep the literal '_VARLOCK_ENV_KEY is not set' in the runtime missing-key
error (changed in #1295), which framework tests assert on (and guard against
with shouldNotContain). Skip the two run-output-drain smoke tests on Windows,
where they have failed on every run since #1296.

* Add empty bump file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant