mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-12 14:19:00 +01:00
Record read_object_body with HTTP status, S3 request id and attempts when a GetObject body stream errors after send() resolved, and add the storage fields to run failure execution diagnostics. Diagnostics only; no retry behavior changes.
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
// Server-only, fixed-shape storage failure details for error reporting. The
|
|
// provider that owns the protocol normalizes them; reporting reads only this
|
|
// record and never the provider's error payload.
|
|
|
|
export type StorageFailureOperation =
|
|
| "put_object"
|
|
| "get_object"
|
|
| "read_object_body"
|
|
| "head_object"
|
|
| "delete_object"
|
|
| "create_multipart_upload"
|
|
| "upload_part"
|
|
| "complete_multipart_upload";
|
|
|
|
export interface StorageFailureDiagnostics {
|
|
provider: "s3";
|
|
operation: StorageFailureOperation;
|
|
errorCode: string;
|
|
httpStatus: number | null;
|
|
requestId: string | null;
|
|
attempts: number | null;
|
|
}
|
|
|
|
const recorded = new WeakMap<object, Readonly<StorageFailureDiagnostics>>();
|
|
|
|
/** Keep the first record: it names the call that actually failed. */
|
|
export function recordStorageFailure(error: unknown, diagnostics: StorageFailureDiagnostics): void {
|
|
if (!error || typeof error !== "object" || recorded.has(error)) return;
|
|
recorded.set(error, Object.freeze({ ...diagnostics }));
|
|
}
|
|
|
|
export function storageFailureDiagnosticsFor(error: unknown): Readonly<StorageFailureDiagnostics> | null {
|
|
if (!error || typeof error !== "object") return null;
|
|
return recorded.get(error) ?? null;
|
|
}
|