fix: security proxy prefers raw runtimeConfig/process.env strings over coerced values - #1420
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
🦋 Changeset detectedLatest commit: eef5902 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
arkenv
@arkenv/build
@arkenv/bun-plugin
@arkenv/cli
@arkenv/fumadocs-ui
@arkenv/nextjs
@arkenv/nuxt
@arkenv/vite-plugin
commit: |
📦 Bundle Size Report✅ All size limits passed! |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the PR fixes the Nuxt security proxy so schema-key reads always return the coerced validation target, and adds regression coverage plus the missing Vitest project config.
packages/nuxt/src/create-env.ts— removes the per-getruntimeConfig/process.env/__NUXT__preference branches fromcreateSecurityProxy.packages/nuxt/src/index.test.ts— updates dynamic config tests to assert coercednumber/booleanvalues and adds tests for the serverprocess.envand client__NUXT__paths.packages/nuxt/src/mock-imports.ts— extracts theuseRuntimeConfigtest mock so#importsresolves cleanly.packages/nuxt/vitest.config.ts— adds the project config required for CI discovery..changeset/fix-nuxt-proxy-coercion.md— patch changeset for@arkenv/nuxt.
I built the required workspace dependencies (@repo/scope, @repo/types, @arkenv/build, arkenv) and verified:
pnpm exec vitest run --project @arkenv/nuxt— 28 tests passed.pnpm --filter @arkenv/nuxt typecheck— clean.
Kimi K2 (free via Pullfrog for OSS) | 𝕏
Keep coerced types when reading from env to ensure number and boolean keys return their respective types at runtime.
Drop "dynamically resolve" / "fallback path" wording that described the old get-time re-read of raw runtimeConfig/process.env strings. Co-authored-by: Yam Borodetsky <hi@yam.codes>
|
Follow-up: renamed the coercion regression tests so they no longer say “dynamically resolve” / “fallback path” (that described the old get-time re-read of raw strings). They now describe create-time sourcing through the proxy. Suggested PR body note (couldn’t edit the description from this agent):
|
Co-authored-by: pullfrog[bot] <226033991+pullfrog[bot]@users.noreply.github.com>
…meconfigprocessenv-strings-over-coerced-values
There was a problem hiding this comment.
Important
The latest changeset edits still leave the ts code block unclosed, which will break the changeset/changelog render.
Reviewed changes — The new commits since df2c3a5a only touched .changeset/fix-nuxt-proxy-coercion.md; they tightened the description but did not add the missing closing fence.
- Updated
.changeset/fix-nuxt-proxy-coercion.md— clarified that coercednumber/booleanvalues are returned at runtime. - Merged current
dev— brought the branch up to date with no semantic conflicts.
Kimi K2 (free via Pullfrog for OSS) | 𝕏
Updated NUXT_PUBLIC_PORT and PORT to use number type.
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to dev, this PR will be updated. # Releases ## @arkenv/cli@0.5.1 ### Patch Changes - #### Add `add host` command to CLI for adding hosting presets to existing schemas _[`#1324`](#1324) [`eed3cce`](eed3cce) [@abhimanyutiwaribot](https://github.com/abhimanyutiwaribot)_ Support adding a hosting provider preset (Vercel or Netlify) to an existing `env.ts` configuration file: ```bash npx @arkenv/cli@latest add host [provider] ``` - Prompts interactively to select Vercel or Netlify if the provider is omitted. - Auto-detects the framework (Next.js, Nuxt, Vite, Bun) and the validator engine (Zod, Valibot, or ArkType) to inject the preset fields with the correct syntax. - Fallback to logging the generated variable schemas to stdout with manual configuration instructions if `env.ts` is missing or unparseable. ## @arkenv/nuxt@0.0.7 ### Patch Changes - #### Fix number and boolean env values returning as strings _[`#1420`](#1420) [`aecac94`](aecac94) [@yamcodes](https://github.com/yamcodes)_ Keep coerced types when reading from `env`. A key declared as `"number"` or `"boolean"` now returns a number or boolean at runtime, not the raw string from Nuxt runtime config. ```ts import { createEnv } from "@arkenv/nuxt"; export const env = createEnv({ NUXT_PUBLIC_PORT: "number", PORT: "number", }); // Was "3000" (string) — now 3000 (number) env.NUXT_PUBLIC_PORT; env.PORT; ``` Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
<!-- CURSOR_AGENT_PR_BODY_BEGIN --> ## Summary - Forward-ports [#1420](#1420) / [#1327](#1327) from `dev` onto `v1` - On `v1`, `createSecurityProxy` in `arkenv-internal.ts` already preferred the coerced validation target (the get-time `runtimeConfig` / `process.env` / `__NUXT__` preference bug never landed here). This port locks that invariant with ADR 0015 docs comments and coercion regression tests. - Adds a `patch` changeset for `@arkenv/nuxt` (v1+ bump rules) ## Notes - Skipped the `useRuntimeConfig` create-time tests from #1420: `v1` `arkenvInternal` does not merge `useRuntimeConfig()` into `sourceEnv` (server uses `process.env`; client uses `__NUXT__` / `process.env`). - Boot-time `NUXT_PUBLIC_*` payload honesty / validator-free client remain #1424. ## Test plan - [x] `pnpm --filter @arkenv/nuxt exec vitest run src/index.test.ts` (7 passed) - [x] `pnpm --filter @arkenv/nuxt typecheck` <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-0623c244-7bc7-41d8-8d5f-7445513461e0"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-0623c244-7bc7-41d8-8d5f-7445513461e0"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>

Fixes #1327
Summary
useRuntimeConfig()/process.env/__NUXT__.config.publicstrings (which silently undid ADR 0002 coercion).useRuntimeConfigtests to assert coercednumber/booleanvalues, and add regression coverage for the serverprocess.envand client__NUXT__paths.@arkenv/nuxtVitest project config so the package tests run in CI.Test plan
pnpm exec vitest run --project @arkenv/nuxtpnpm run typecheckpnpm run testpnpm run fixMade with Cursor