mirror of
https://github.com/morluto/rea.git
synced 2026-11-14 02:32:54 +00:00
fix(workers): reject malformed UTF-8 in JSON result files
This commit is contained in:
1 parent
1d32eb3aa4
commit
c2b0c955cd
6 files changed
+283
-9
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { safeParseUtf8Json } from "../domain/safeJson.js";
|
||||
import {
|
||||
bindArtifactFileCleanup,
|
||||
artifactFileCancellationCause,
|
||||
@@ -269,7 +270,9 @@ export const executeSqliteDatabaseWorker = async (request: {
|
||||
finalization = sqliteReplyCompletionFailure(cause, capturedOutput);
|
||||
file = completed;
|
||||
}
|
||||
reply = replySchema.parse(JSON.parse(file.bytes.toString("utf8")));
|
||||
const decoded = safeParseUtf8Json(file.bytes);
|
||||
if (!decoded.ok) throw decoded.cause;
|
||||
reply = replySchema.parse(decoded.value);
|
||||
} catch (cause: unknown) {
|
||||
throw sqliteReplyFinalizationFailure(
|
||||
sqliteReplyReadFailure(cause, capturedOutput),
|
||||
|
||||
Reference in new issue
Block a user