From 4314251cd77779328548a16699c2c9b2383a2565 Mon Sep 17 00:00:00 2001 From: sebastianMindee <130448732+sebastianMindee@users.noreply.github.com> Date: Mon, 20 Jul 2026 17:35:19 +0200 Subject: [PATCH 1/3] :sparkles: add webhook error response --- src/v2/parsing/failedInferenceResponse.ts | 49 +++++++++++++++++++ src/v2/parsing/job/jobResponse.ts | 3 ++ tests/data | 2 +- .../parsing/failedInferenceResponse.spec.ts | 26 ++++++++++ 4 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 src/v2/parsing/failedInferenceResponse.ts create mode 100644 tests/v2/parsing/failedInferenceResponse.spec.ts diff --git a/src/v2/parsing/failedInferenceResponse.ts b/src/v2/parsing/failedInferenceResponse.ts new file mode 100644 index 000000000..d9f51c8df --- /dev/null +++ b/src/v2/parsing/failedInferenceResponse.ts @@ -0,0 +1,49 @@ +import { parseDate, StringDict } from "@/parsing/index.js"; +import { ErrorResponse } from "@/v2/index.js"; +import { BaseResponse } from "@/v2/parsing/baseResponse.js"; + +/** + * Webhook payload returned when an inference fails before producing a result. + */ +export class FailedInferenceResponse extends BaseResponse { + /** + * UUID of the failed inference. + */ + public inferenceId: string; + + /** + * UUID of the model used. + */ + public modelId: string; + + /** + * Name of the input file. + */ + public fileName: string; + + /** + * Alias sent for the file, if any. + */ + public fileAlias?: string; + + /** + * Problem details for the failure, if available. + */ + public error: ErrorResponse; + + /** + * Date and time when the inference was started. + */ + public createdAt: Date | null; + + + constructor(serverResponse: StringDict) { + super(serverResponse); + this.inferenceId = serverResponse["inference_id"]; + this.modelId = serverResponse["model_id"]; + this.fileName = serverResponse["file_name"]; + this.fileAlias = serverResponse["file_alias"]; + this.error = new ErrorResponse(serverResponse["error"]); + this.createdAt = parseDate(serverResponse["created_at"]); + } +} diff --git a/src/v2/parsing/job/jobResponse.ts b/src/v2/parsing/job/jobResponse.ts index 2d42a89af..7ee26cdd6 100644 --- a/src/v2/parsing/job/jobResponse.ts +++ b/src/v2/parsing/job/jobResponse.ts @@ -2,6 +2,9 @@ import { BaseResponse } from "@/v2/parsing/baseResponse.js"; import { StringDict } from "@/parsing/stringDict.js"; import { Job } from "./job.js"; +/** + * Job response class. + */ export class JobResponse extends BaseResponse { /** * Job for the polling. diff --git a/tests/data b/tests/data index 2d7fcf8f5..e41ab97c2 160000 --- a/tests/data +++ b/tests/data @@ -1 +1 @@ -Subproject commit 2d7fcf8f591f6d7f40e39862965325e6a8a21874 +Subproject commit e41ab97c2833f15ea5c4edf221c2d197d212f632 diff --git a/tests/v2/parsing/failedInferenceResponse.spec.ts b/tests/v2/parsing/failedInferenceResponse.spec.ts new file mode 100644 index 000000000..b66900baa --- /dev/null +++ b/tests/v2/parsing/failedInferenceResponse.spec.ts @@ -0,0 +1,26 @@ +import assert from "node:assert/strict"; +import { describe, it } from "node:test"; +import path from "path"; +import { ErrorResponse, LocalResponse } from "../../../src/v2/index.js"; +import { FailedInferenceResponse } from "../../../src/v2/parsing/failedInferenceResponse.js"; +import { V2_RESOURCE_PATH } from "../../index.js"; + +describe("MindeeV2 - Failed Inference Response", async () => { + + it("should load", async () => { + + const localResponse = new LocalResponse(path.join(V2_RESOURCE_PATH, "errors", "webhook_error_500_failed.json")); + await localResponse.init(); + const response = await localResponse.deserializeResponse(FailedInferenceResponse); + + assert.ok(response); + assert.equal(response.inferenceId, "12345678-1234-1234-1234-123456789ABC"); + assert.equal(response.fileName, "default_sample.jpg"); + assert.equal(response.fileAlias, "dummy-alias.jpg"); + assert.ok(response.createdAt); + assert.ok(response.createdAt instanceof Date); + assert.ok(response.error instanceof ErrorResponse); + assert.equal(response.error.status, 500); + assert.equal(response.error.code, "500-012"); + }); +}); From 643d37187fda670cec732e21ffdf6e31a070588f Mon Sep 17 00:00:00 2001 From: sebastianMindee <130448732+sebastianMindee@users.noreply.github.com> Date: Mon, 20 Jul 2026 17:36:10 +0200 Subject: [PATCH 2/3] bump deps --- package-lock.json | 48 ----------------------------------------------- 1 file changed, 48 deletions(-) diff --git a/package-lock.json b/package-lock.json index b1fc40294..c8c711537 100644 --- a/package-lock.json +++ b/package-lock.json @@ -915,9 +915,6 @@ "cpu": [ "arm" ], - "libc": [ - "glibc" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -934,9 +931,6 @@ "cpu": [ "arm64" ], - "libc": [ - "glibc" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -953,9 +947,6 @@ "cpu": [ "ppc64" ], - "libc": [ - "glibc" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -972,9 +963,6 @@ "cpu": [ "riscv64" ], - "libc": [ - "glibc" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -991,9 +979,6 @@ "cpu": [ "s390x" ], - "libc": [ - "glibc" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -1010,9 +995,6 @@ "cpu": [ "x64" ], - "libc": [ - "glibc" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -1029,9 +1011,6 @@ "cpu": [ "arm64" ], - "libc": [ - "musl" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -1048,9 +1027,6 @@ "cpu": [ "x64" ], - "libc": [ - "musl" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -1067,9 +1043,6 @@ "cpu": [ "arm" ], - "libc": [ - "glibc" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1092,9 +1065,6 @@ "cpu": [ "arm64" ], - "libc": [ - "glibc" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1117,9 +1087,6 @@ "cpu": [ "ppc64" ], - "libc": [ - "glibc" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1142,9 +1109,6 @@ "cpu": [ "riscv64" ], - "libc": [ - "glibc" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1167,9 +1131,6 @@ "cpu": [ "s390x" ], - "libc": [ - "glibc" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1192,9 +1153,6 @@ "cpu": [ "x64" ], - "libc": [ - "glibc" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1217,9 +1175,6 @@ "cpu": [ "arm64" ], - "libc": [ - "musl" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1242,9 +1197,6 @@ "cpu": [ "x64" ], - "libc": [ - "musl" - ], "license": "Apache-2.0", "optional": true, "os": [ From 6b58f4f3b42a1bceb332bddc25f698842ceb8491 Mon Sep 17 00:00:00 2001 From: sebastianMindee <130448732+sebastianMindee@users.noreply.github.com> Date: Tue, 21 Jul 2026 15:33:03 +0200 Subject: [PATCH 3/3] move to proper folder --- src/v2/parsing/{ => inference}/failedInferenceResponse.ts | 0 tests/v2/parsing/failedInferenceResponse.spec.ts | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename src/v2/parsing/{ => inference}/failedInferenceResponse.ts (100%) diff --git a/src/v2/parsing/failedInferenceResponse.ts b/src/v2/parsing/inference/failedInferenceResponse.ts similarity index 100% rename from src/v2/parsing/failedInferenceResponse.ts rename to src/v2/parsing/inference/failedInferenceResponse.ts diff --git a/tests/v2/parsing/failedInferenceResponse.spec.ts b/tests/v2/parsing/failedInferenceResponse.spec.ts index b66900baa..e6ca1587b 100644 --- a/tests/v2/parsing/failedInferenceResponse.spec.ts +++ b/tests/v2/parsing/failedInferenceResponse.spec.ts @@ -2,7 +2,7 @@ import assert from "node:assert/strict"; import { describe, it } from "node:test"; import path from "path"; import { ErrorResponse, LocalResponse } from "../../../src/v2/index.js"; -import { FailedInferenceResponse } from "../../../src/v2/parsing/failedInferenceResponse.js"; +import { FailedInferenceResponse } from "../../../src/v2/parsing/inference/failedInferenceResponse.js"; import { V2_RESOURCE_PATH } from "../../index.js"; describe("MindeeV2 - Failed Inference Response", async () => {