Chore/v2/transforms as root (#5868)

Any task that changes file type or produces more/fewer files than the
input are now consumed as root files not incremented versions of the
input.
This commit is contained in:
Reece Browne
2026-03-06 13:46:40 +00:00
committed by GitHub
parent a57e336675
commit 63d38e382d
9 changed files with 380 additions and 258 deletions
@@ -34,6 +34,46 @@ export const createStandardErrorHandler = (fallbackMessage: string) => {
};
};
/**
* Parses a 422 response, extracts errored file IDs from the payload (JSON or UUID regex),
* and marks them in the UI. Returns true if IDs were found and handled, false otherwise.
*/
export const handle422Error = async (
error: any,
markFileError: (fileId: string) => void
): Promise<boolean> => {
const status = error?.response?.status;
if (typeof status !== 'number' || status !== 422) return false;
const payload = error?.response?.data;
let parsed: unknown = payload;
if (typeof payload === 'string') {
try { parsed = JSON.parse(payload); } catch { parsed = payload; }
} else if (payload && typeof (payload as Blob).text === 'function') {
const text = await (payload as Blob).text();
try { parsed = JSON.parse(text); } catch { parsed = text; }
}
let ids: string[] | undefined = Array.isArray((parsed as { errorFileIds?: unknown })?.errorFileIds)
? (parsed as { errorFileIds: string[] }).errorFileIds
: undefined;
if (!ids && typeof parsed === 'string') {
const match = parsed.match(/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/g);
if (match && match.length > 0) ids = Array.from(new Set(match));
}
if (ids && ids.length > 0) {
for (const id of ids) {
try { markFileError(id); } catch (_e) { void _e; }
}
return true;
}
return false;
};
/**
* Handles password-related errors with status code checking
* @param error - The error object from axios