You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(appkit): don't misdirect cache-unrelated typegen fatals to .appkit/
Make TypegenFatalError's cacheInitialized snapshot optional. A cache-unrelated
fatal (e.g. a malformed definitions.json) now omits it and gets generic
"Fix the FATAL error(s) above, then re-run generate-types" wording, instead of
the bootstrap/drift message telling the operator to regenerate and commit
.appkit/ (which only applies to failures tied to the type cache).
Co-authored-by: Isaac
Signed-off-by: Atila Fassina <atila@fassina.eu>
Copy file name to clipboardExpand all lines: packages/appkit/src/type-generator/index.ts
+18-10Lines changed: 18 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -178,17 +178,25 @@ export class TypegenFatalError extends Error {
178
178
constructor(
179
179
queries: QueryFatalError[],
180
180
warehouseId?: string,
181
-
cacheInitialized: boolean=true,
181
+
cacheInitialized?: boolean,
182
182
){
183
-
// Distinguish bootstrap (no committed cache yet) from drift (cache exists but is stale/missing key).
184
-
// Bootstrap → operator needs to initialize; drift → operator needs to regenerate the affected key.
185
-
constnextStep=cacheInitialized
186
-
? // Drift: cache file exists but is missing/stale for the failing query/metric.
187
-
warehouseId
188
-
? `The committed ${pc.bold(".appkit/")} cache is missing or stale for the failed ${plural(queries.length,"query","queries")}. Regenerate with ${pc.bold("generate-types --wait")} against warehouse ${pc.bold(warehouseId)} and commit ${pc.bold(".appkit/")}.`
189
-
: `The committed ${pc.bold(".appkit/")} cache is missing or stale for the failed ${plural(queries.length,"query","queries")}. Regenerate with ${pc.bold("generate-types --wait")} against a warehouse and commit ${pc.bold(".appkit/")}.`
190
-
: // Bootstrap: no committed cache found; operator needs to initialize from scratch.
191
-
`No committed type cache found (${pc.bold(".appkit/")}). Run ${pc.bold("generate-types --wait")} against a warehouse and commit ${pc.bold(".appkit/")} before building without warehouse access.`;
183
+
// The cache snapshot is optional: callers whose failure relates to the type
184
+
// cache pass it to get bootstrap/drift remediation; callers with an unrelated
185
+
// fatal (e.g. a malformed definitions.json) omit it and get generic wording.
186
+
constnextStep=
187
+
cacheInitialized===undefined
188
+
? // No cache snapshot: the failure is unrelated to the cache — don't
189
+
// misdirect the operator toward regenerating/committing `.appkit/`.
190
+
`Fix the ${pc.bold("FATAL")} error(s) above, then re-run ${pc.bold("generate-types")}.`
191
+
: // Distinguish bootstrap (no committed cache yet) from drift (cache exists but is stale/missing key).
192
+
// Bootstrap → operator needs to initialize; drift → operator needs to regenerate the affected key.
193
+
cacheInitialized
194
+
? // Drift: cache file exists but is missing/stale for the failing query/metric.
195
+
warehouseId
196
+
? `The committed ${pc.bold(".appkit/")} cache is missing or stale for the failed ${plural(queries.length,"query","queries")}. Regenerate with ${pc.bold("generate-types --wait")} against warehouse ${pc.bold(warehouseId)} and commit ${pc.bold(".appkit/")}.`
197
+
: `The committed ${pc.bold(".appkit/")} cache is missing or stale for the failed ${plural(queries.length,"query","queries")}. Regenerate with ${pc.bold("generate-types --wait")} against a warehouse and commit ${pc.bold(".appkit/")}.`
198
+
: // Bootstrap: no committed cache found; operator needs to initialize from scratch.
199
+
`No committed type cache found (${pc.bold(".appkit/")}). Run ${pc.bold("generate-types --wait")} against a warehouse and commit ${pc.bold(".appkit/")} before building without warehouse access.`;
0 commit comments