mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-05 17:30:50 +00:00
A source that answers with a JSON error body still reached ffprobe and
produced `moov atom not found`. Replicate returns
`{"detail": "requested file not found"}` for a dead asset, and a gateway
in front of it can relay that body with a success status.
The sniff now treats `<`, `{`, or `[` as the opening byte of a text
document. No supported container starts with any of them, so this is the
same trade as before: three bytes instead of an allowlist that grows one
entry per payload shape observed in production.
Renamed accordingly, since the class now covers JSON as well as markup:
MARKUP_NOT_MEDIA -> NOT_MEDIA_PAYLOAD, MarkupNotMediaError ->
NotMediaPayloadError, markupPayload.ts -> notMediaPayload.ts. Registry
entries in the Lambda name map, the CDK and SAM plan lists, the Cloud Run
set, and SAFE_RENDER_ERROR_CODES move with it.
Also documents the reachability boundary on the error class: only a 2xx
response gets here. `downloadToTemp` rejects 404/410 as `http_not_found`
before writing a byte, and every ffprobe input is local because
videoFrameExtractor downloads http srcs first. So the shapes this
classifies are soft-404 and interstitial HTML, S3/CloudFront error
documents, and JSON API error bodies -- each served with a success
status. A genuine 404 surfaces as a download failure, not as this error.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
20 lines
964 B
TypeScript
20 lines
964 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { NotMediaPayloadError } from "@hyperframes/engine";
|
|
import { extractSafeRenderErrorMetadata } from "./server.js";
|
|
|
|
// Kept out of server.errorCode.test.ts so that suite keeps exactly one typed
|
|
// error class in scope: two same-shaped classes there defeat the dead-code
|
|
// analyzer's member resolution and it reports the sibling's fields as unused.
|
|
describe("extractSafeRenderErrorMetadata — non-media payloads", () => {
|
|
it("transports the code, owner, and retry policy", () => {
|
|
// Without the SAFE_RENDER_ERROR_CODES entry the API emits
|
|
// `errorCode: undefined` and the failure is indistinguishable from an
|
|
// untyped crash — as unroutable as the `moov atom not found` it replaces.
|
|
expect(extractSafeRenderErrorMetadata(new NotMediaPayloadError(["0123456789abcdef"]))).toEqual({
|
|
errorCode: "NOT_MEDIA_PAYLOAD",
|
|
errorOwner: "user",
|
|
retryable: false,
|
|
});
|
|
});
|
|
});
|