Detect and validate app runtime from uploaded archives.

Reject zip uploads when the selected runtime does not match archive contents, and re-validate before Kaniko builds to fail fast instead of producing the wrong Dockerfile.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
keyhan
2026-06-30 00:27:03 +03:30
parent 837f0fa63f
commit 8d1855b89c
21 changed files with 654 additions and 98 deletions
+24
View File
@@ -22,6 +22,30 @@ export interface ClassifiedError {
backendMessage?: string;
}
export interface RuntimeMismatchPayload {
configured: string;
detected: string;
signals?: string[];
}
/** Reads structured runtime mismatch fields from a 400 upload response. */
export function readRuntimeMismatch(err: unknown): RuntimeMismatchPayload | null {
if (!axios.isAxiosError(err) || err.response?.status !== 400) return null;
const data = err.response.data;
if (!data || typeof data !== 'object') return null;
const body = data as Record<string, unknown>;
if (typeof body.configured === 'string' && typeof body.detected === 'string') {
return {
configured: body.configured,
detected: body.detected,
signals: Array.isArray(body.signals)
? body.signals.filter((s): s is string => typeof s === 'string')
: undefined,
};
}
return null;
}
/** Flattens NestJS-style `message: string | string[]` into one string. */
function readBackendMessage(data: unknown): string | undefined {
if (!data || typeof data !== 'object') return undefined;