Skip to content

Commit f2d44ae

Browse files
fix: fail typegen build when queries produce unknown result types (#254)
* Fail typegen build when queries produce unknown result types When DESCRIBE QUERY fails, typegen silently generates `result: unknown` and reports success, causing downstream TypeScript compilation errors. Now typegen throws an error listing the failed queries, so the build fails early with a clear message instead of producing unusable types. Fixes #244 * Improve typegen error message with actionable debugging guidance The error message now points users to the error codes printed above, lists common causes, and suggests running the query directly in a SQL editor against the specific warehouse to debug.
1 parent afe5b7d commit f2d44ae

File tree

1 file changed

+15
-0
lines changed
  • packages/appkit/src/type-generator

1 file changed

+15
-0
lines changed

packages/appkit/src/type-generator/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,21 @@ export async function generateFromEntryPoint(options: {
6565
},
6666
);
6767

68+
const failedQueries = queryRegistry.filter((q) =>
69+
q.type.includes("result: unknown"),
70+
);
71+
if (failedQueries.length > 0) {
72+
const names = failedQueries.map((q) => q.name).join(", ");
73+
throw new Error(
74+
[
75+
`Type generation failed: ${failedQueries.length} ${failedQueries.length === 1 ? "query" : "queries"} could not be described: ${names}.`,
76+
`DESCRIBE QUERY failed for these queries — see the error codes above for details.`,
77+
`Common causes: SQL syntax errors, missing tables/views, or warehouse format incompatibilities.`,
78+
`To debug: run the failing query directly in a SQL editor against warehouse ${warehouseId}.`,
79+
].join("\n"),
80+
);
81+
}
82+
6883
const typeDeclarations = generateTypeDeclarations(queryRegistry);
6984

7085
await fs.writeFile(outFile, typeDeclarations, "utf-8");

0 commit comments

Comments
 (0)