|
| 1 | +--- |
| 2 | +title: Raw Convex auth adoption must install kitcn runtime before codegen |
| 3 | +date: 2026-04-15 |
| 4 | +category: integration-issues |
| 5 | +module: auth-adoption |
| 6 | +problem_type: integration_issue |
| 7 | +component: tooling |
| 8 | +severity: high |
| 9 | +symptoms: |
| 10 | + - '`kitcn add auth --preset convex --yes` fails during Convex bootstrap with `Could not resolve "kitcn/auth"` or `Could not resolve "kitcn/auth/http"`' |
| 11 | + - raw Convex auth adoption writes `convex/auth.ts`, `convex/http.ts`, and `src/lib/convex/auth-client.ts`, but the app `package.json` still lacks `kitcn`' |
| 12 | + - local scenario runs with `KITCN_INSTALL_SPEC` can end up with duplicate `kitcn` dependency keys if the hint is pre-resolved too early' |
| 13 | +root_cause: missing_tooling |
| 14 | +resolution_type: code_fix |
| 15 | +tags: |
| 16 | + - convex |
| 17 | + - auth |
| 18 | + - cli |
| 19 | + - scaffolding |
| 20 | + - package-management |
| 21 | + - scenarios |
| 22 | +--- |
| 23 | + |
| 24 | +# Raw Convex auth adoption must install kitcn runtime before codegen |
| 25 | + |
| 26 | +## Problem |
| 27 | + |
| 28 | +The raw Convex auth preset generated files that import `kitcn/*`, but the |
| 29 | +install plan only guaranteed `better-auth` and OpenTelemetry. |
| 30 | + |
| 31 | +That meant `kitcn add auth --preset convex --yes` could scaffold the right |
| 32 | +files and then immediately die when Convex tried to bundle them. |
| 33 | + |
| 34 | +## Symptoms |
| 35 | + |
| 36 | +- `convex/auth.ts` imports `kitcn/auth`, but the app has no `kitcn` |
| 37 | + dependency |
| 38 | +- Convex bootstrap fails before JWKS sync with unresolved `kitcn/*` imports |
| 39 | +- local scenario runs can show duplicate `kitcn` keys in `package.json` if the |
| 40 | + dependency hint is stored as a pre-resolved tarball path |
| 41 | + |
| 42 | +## What Didn't Work |
| 43 | + |
| 44 | +- treating `better-auth` as the only runtime dependency for the raw preset |
| 45 | +- storing the raw preset hint as an already-resolved install spec like |
| 46 | + `file:/.../kitcn-0.12.27.tgz` |
| 47 | + |
| 48 | +The second cut was especially sneaky: it fixed published installs, but it |
| 49 | +defeated package-name detection during local scenario runs, so the CLI could no |
| 50 | +longer tell that `kitcn` was already present. |
| 51 | + |
| 52 | +## Solution |
| 53 | + |
| 54 | +Keep the raw preset dependency hint at the package-name level: |
| 55 | + |
| 56 | +- declare `kitcn` as a raw auth scaffold dependency hint |
| 57 | +- resolve that hint to the current package install spec only at install time |
| 58 | + |
| 59 | +That keeps both paths honest: |
| 60 | + |
| 61 | +1. published CLI runs install `kitcn@<current-version>` |
| 62 | +2. local scenario runs still collapse to the tarball override from |
| 63 | + `KITCN_INSTALL_SPEC` |
| 64 | +3. duplicate detection still works because the missing-dependency scan compares |
| 65 | + against the raw package name `kitcn`, not a tarball URL |
| 66 | + |
| 67 | +## Why This Works |
| 68 | + |
| 69 | +The raw preset contract is different from the managed kitcn baseline. |
| 70 | + |
| 71 | +Managed apps already depend on `kitcn`, so auth scaffolding can assume the |
| 72 | +runtime helpers exist. Raw Convex adoption cannot. It patches a foreign app in |
| 73 | +place, so every emitted `kitcn/*` import must be matched by an explicit |
| 74 | +dependency install before codegen or local bootstrap runs. |
| 75 | + |
| 76 | +Resolving the install spec too early turns `kitcn` into an opaque file URL, |
| 77 | +which breaks the package-name check that prevents duplicate installs. |
| 78 | + |
| 79 | +## Prevention |
| 80 | + |
| 81 | +1. If a preset emits `kitcn/*` imports into an app that did not come from |
| 82 | + `kitcn init`, treat `kitcn` as an explicit scaffold dependency. |
| 83 | +2. Keep dependency hints as package-name specs until install time. Resolve |
| 84 | + local tarball overrides as late as possible. |
| 85 | +3. Keep `raw-start-auth-adoption` in the scenario gate. This bug is easy to |
| 86 | + miss in file-only tests and obvious in the real bootstrap lane. |
| 87 | + |
| 88 | +## Related Issues |
| 89 | + |
| 90 | +- `docs/solutions/integration-issues/raw-convex-auth-adoption-bootstrap-20260318.md` |
| 91 | +- `docs/solutions/integration-issues/raw-convex-start-auth-adoption-must-patch-start-provider-and-react-client-20260410.md` |
0 commit comments