Skip to content

Commit 5010cd2

Browse files
authored
Merge pull request #212 from udecode/codex/208-209-deploy-env-passthrough
2 parents fafaac0 + 8621c9c commit 5010cd2

17 files changed

Lines changed: 304 additions & 14 deletions

File tree

.changeset/raw-convex-auth-kitcn.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66

77
- Fix raw Convex auth adoption so `kitcn add auth --preset convex --yes`
88
installs `kitcn` before codegen and local bootstrap.
9+
- Fix `kitcn deploy` so CI deployment env vars reach Convex deploy, migrations,
10+
and aggregate backfill.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Issues 208 and 209 deploy env passthrough
2+
3+
## Context
4+
5+
- Source: GitHub issues #208 and #209.
6+
- Bug: `kitcn deploy` does not pass ambient Convex deployment env to the
7+
`convex deploy` subprocess.
8+
- User-visible failure: CI sees no deployment config even when
9+
`CONVEX_DEPLOY_KEY` is set.
10+
- Comment on #208 confirms `--env-file` workaround and points to #209.
11+
12+
## Acceptance
13+
14+
- `kitcn deploy` passes ambient Convex deployment env vars to `convex deploy`.
15+
- `kitcn dev` and `kitcn codegen` keep clearing ambient deployment env by
16+
default.
17+
- Regression coverage proves deploy env passthrough through the CLI runner.
18+
- Published package change updates the active unreleased changeset.
19+
20+
## Verification
21+
22+
- Targeted red-green test in `packages/kitcn/src/cli/cli.commands.ts`.
23+
- `bun test ./packages/kitcn/src/cli/cli.commands.ts`.
24+
- `bun --cwd packages/kitcn build`.
25+
- `lint:fix`, `typecheck`, `check` before PR.
26+
27+
## Notes
28+
29+
- No browser surface.
30+
- The deploy fix had no scaffold impact. PR gate exposed a Start auth scaffold
31+
route issue, so fixture sync/check became required and passed.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
title: kitcn deploy must forward Convex deployment env
3+
date: 2026-04-15
4+
category: integration-issues
5+
module: cli
6+
problem_type: integration_issue
7+
component: tooling
8+
symptoms:
9+
- `kitcn deploy` fails in CI even when `CONVEX_DEPLOY_KEY` is set
10+
- Convex reports missing deployment configuration or asks for `convex login`
11+
- `bunx convex deploy` works with the same CI environment
12+
root_cause: wrong_api
13+
resolution_type: code_fix
14+
severity: high
15+
tags:
16+
- convex
17+
- deploy
18+
- ci
19+
- env
20+
- cli
21+
---
22+
23+
# kitcn deploy must forward Convex deployment env
24+
25+
## Problem
26+
27+
`kitcn deploy` wrapped `convex deploy` with `createBackendCommandEnv()` and
28+
therefore cleared `CONVEX_DEPLOY_KEY`, `CONVEX_DEPLOYMENT`, and self-hosted
29+
deployment env vars. CI deploys then fell back to anonymous or unconfigured
30+
Convex behavior.
31+
32+
## Symptoms
33+
34+
- CI logs say no Convex deployment configuration was found.
35+
- Convex suggests `convex login`, which is wrong for CI.
36+
- Passing `--env-file` works because Convex reads that file itself.
37+
38+
## What Didn't Work
39+
40+
- Keeping the deployment env wipe globally. That is correct for local dev and
41+
codegen, but deploy is the opposite contract: ambient CI env is the target.
42+
- Forwarding env only to the first `convex deploy` call. Post-deploy migration
43+
and aggregate backfill calls also need the same deployment target.
44+
45+
## Solution
46+
47+
Keep the default backend env wipe, but add a deploy-specific override sourced
48+
from the ambient Convex deployment env keys.
49+
50+
```ts
51+
const deployCommandEnv =
52+
backend === 'convex' ? getConvexDeploymentCommandEnv() : undefined;
53+
54+
env: createBackendCommandEnv(deployCommandEnv);
55+
```
56+
57+
Pass the same `deployCommandEnv` into post-deploy migration and aggregate
58+
backfill flows so the whole deploy pipeline targets the same deployment.
59+
60+
## Why This Works
61+
62+
Convex deployment env is not incidental process noise in CI. It is the target
63+
selection API for `convex deploy` and follow-up `convex run` calls.
64+
65+
`kitcn dev` and `kitcn codegen` still clear ambient deployment env by default,
66+
so stale shell variables do not hijack local development.
67+
68+
## Prevention
69+
70+
- Test deploy wrappers with ambient `CONVEX_DEPLOY_KEY`, not only CLI flags.
71+
- When a deploy command fans out into post-deploy `run` commands, carry the
72+
same target env through the whole flow.
73+
74+
## Related Issues
75+
76+
- [#208](https://github.com/udecode/kitcn/issues/208)
77+
- [#209](https://github.com/udecode/kitcn/issues/209)
78+
- [kitcn dev must honor remote Convex deployments from .env.local](/Users/zbeyens/git/better-convex/docs/solutions/integration-issues/dev-must-honor-remote-convex-deployments-from-env-local-20260404.md)
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
title: Start auth routes must use literal createFileRoute paths
3+
date: 2026-04-15
4+
category: integration-issues
5+
module: cli
6+
problem_type: integration_issue
7+
component: tooling
8+
symptoms:
9+
- TanStack Router generation fails with `expected route id to be a string literal or plain template literal`
10+
- Start auth smoke fails after route generation leaves the API route unusable
11+
- Plain `tsc` fails when new route files are present but `routeTree.gen.ts` is stale
12+
root_cause: wrong_api
13+
resolution_type: code_fix
14+
severity: medium
15+
tags:
16+
- tanstack-start
17+
- auth
18+
- routes
19+
- scaffold
20+
- cli
21+
---
22+
23+
# Start auth routes must use literal createFileRoute paths
24+
25+
## Problem
26+
27+
The Start auth scaffold emitted `createFileRoute('/auth' as never)` and
28+
`createFileRoute('/api/auth/$' as never)`. The cast hid stale
29+
`routeTree.gen.ts` type errors, but current TanStack Router generation rejects
30+
non-literal route arguments at runtime.
31+
32+
## Symptoms
33+
34+
- Vite logs `expected route id to be a string literal or plain template literal`.
35+
- `/api/auth/sign-up/email` returns a 500 because the Start auth route never
36+
registers cleanly.
37+
- Replacing the cast with a clean literal fixes generation but makes fixture
38+
`typecheck` fail until TanStack refreshes `routeTree.gen.ts`.
39+
40+
## What Didn't Work
41+
42+
- Keeping `as never`. It satisfies TypeScript but violates the router
43+
generator's parser contract.
44+
- Using only clean literals. That works after route generation but fails the
45+
repo's plain `tsc` fixture validation while `routeTree.gen.ts` is stale.
46+
47+
## Solution
48+
49+
Emit literal route paths and use a narrow `@ts-ignore` for the stale route tree
50+
window.
51+
52+
```ts
53+
// @ts-ignore routeTree.gen.ts is refreshed by TanStack Router during dev/build.
54+
export const Route = createFileRoute('/auth')({
55+
component: AuthPage,
56+
});
57+
```
58+
59+
The generator sees the literal route path, and plain typecheck survives until
60+
TanStack updates `routeTree.gen.ts`.
61+
62+
## Why This Works
63+
64+
TanStack has two separate contracts here:
65+
66+
- route generation needs a literal AST node
67+
- TypeScript needs `routeTree.gen.ts` to include the new route IDs
68+
69+
The scaffold has to satisfy both during the gap between writing route files and
70+
running dev/build generation.
71+
72+
## Prevention
73+
74+
- Do not use type casts inside `createFileRoute(...)` arguments in generated
75+
Start routes.
76+
- Verify Start auth changes with `scenario:test -- start-auth`, not just
77+
fixture typecheck.
78+
79+
## Related Issues
80+
81+
- [raw Convex Start auth adoption must patch Start provider and React client](/Users/zbeyens/git/better-convex/docs/solutions/integration-issues/raw-convex-start-auth-adoption-must-patch-start-provider-and-react-client-20260410.md)
82+
- [start auth reload must rehydrate from persisted session token](/Users/zbeyens/git/better-convex/docs/solutions/integration-issues/start-auth-reload-must-rehydrate-from-persisted-session-token-20260408.md)

fixtures/next-auth/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"dependencies": {
3-
"@base-ui/react": "^1.3.0",
3+
"@base-ui/react": "^1.4.0",
44
"@opentelemetry/api": "1.9.0",
55
"@tanstack/react-query": "5.95.2",
66
"better-auth": "1.5.3",

fixtures/next/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"dependencies": {
3-
"@base-ui/react": "^1.3.0",
3+
"@base-ui/react": "^1.4.0",
44
"@opentelemetry/api": "1.9.0",
55
"@tanstack/react-query": "5.95.2",
66
"class-variance-authority": "^0.7.1",

fixtures/start-auth/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"dependencies": {
3-
"@base-ui/react": "^1.3.0",
3+
"@base-ui/react": "^1.4.0",
44
"@fontsource-variable/geist": "^5.2.8",
55
"@opentelemetry/api": "1.9.0",
66
"@tailwindcss/vite": "^4.1.18",

fixtures/start-auth/src/routes/api/auth/$.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { createFileRoute } from '@tanstack/react-router';
22

33
import { handler } from '@/lib/convex/auth-server';
44

5-
export const Route = createFileRoute('/api/auth/$' as never)({
5+
// @ts-ignore routeTree.gen.ts is refreshed by TanStack Router during dev/build.
6+
export const Route = createFileRoute('/api/auth/$')({
67
server: {
78
handlers: {
89
GET: ({ request }) => handler(request),

fixtures/start-auth/src/routes/auth.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import {
1212
useSignUpMutationOptions,
1313
} from '@/lib/convex/auth-client';
1414

15-
export const Route = createFileRoute('/auth' as never)({
15+
// @ts-ignore routeTree.gen.ts is refreshed by TanStack Router during dev/build.
16+
export const Route = createFileRoute('/auth')({
1617
component: AuthPage,
1718
});
1819

fixtures/start/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"dependencies": {
3-
"@base-ui/react": "^1.3.0",
3+
"@base-ui/react": "^1.4.0",
44
"@fontsource-variable/geist": "^5.2.8",
55
"@opentelemetry/api": "1.9.0",
66
"@tailwindcss/vite": "^4.1.18",

0 commit comments

Comments
 (0)