fix(producer): validate render request engine snapshots

This commit is contained in:
James
2026-07-17 16:22:23 -04:00
parent 25dd4cc8c0
commit fc4e9a6c0e
5 changed files with 238 additions and 5 deletions
@@ -174,6 +174,35 @@ describe("RenderRequest", () => {
).toThrow("distributed.width");
});
it("requires complete and valid engine config snapshots on both wire paths", () => {
const value = request();
for (const engineConfig of [
{},
{ ...value.options.engineConfig, protocolTimeout: "forever" },
{ ...value.options.engineConfig, browserGpuMode: "turbo" },
]) {
expect(() =>
parseRenderRequest({ ...value, options: { ...value.options, engineConfig } }),
).toThrow("Engine config");
}
for (const engineConfig of [
{},
{ ...value.options.engineConfig, protocolTimeout: "forever" },
{ ...value.options.engineConfig, browserGpuMode: "turbo" },
]) {
const distributed = distributedConfigFromRequest(value);
(distributed as { engineConfig: unknown }).engineConfig = engineConfig;
expect(() =>
renderRequestFromDistributedConfig({
projectDir: value.projectDir,
outputPath: value.outputPath,
config: distributed,
}),
).toThrow("Engine config");
}
});
it("validates the reverse distributed adapter at the wire boundary", () => {
const distributed = distributedConfigFromRequest(request());
distributed.width = 1921;
+2 -3
View File
@@ -1,6 +1,7 @@
import {
isVideoFrameFormat,
resolveConfig,
validateEngineConfigSnapshot,
type EngineConfig,
type VideoFrameFormat,
} from "@hyperframes/engine";
@@ -176,9 +177,7 @@ function assertRequestOptionScalars(options: Record<string, unknown>): void {
}
function assertRequestOptionObjects(options: Record<string, unknown>): void {
if (!isPlainObject(options.engineConfig)) {
throw new Error("Render request must contain a resolved engineConfig snapshot");
}
validateEngineConfigSnapshot(options.engineConfig);
if (options.variables !== undefined && !isPlainObject(options.variables)) {
throw new Error("Render request variables must be a JSON object");
}
@@ -17,7 +17,11 @@
* needs the actual planner.
*/
import { VIDEO_FRAME_FORMATS, isVideoFrameFormat } from "@hyperframes/engine";
import {
VIDEO_FRAME_FORMATS,
isVideoFrameFormat,
validateEngineConfigSnapshot,
} from "@hyperframes/engine";
import { type DistributedFormat } from "./shared.js";
import { type DistributedRenderConfig } from "./plan.js";
@@ -204,7 +208,7 @@ export function validateDistributedRenderConfig(
validateVariablesPayload(config.variables);
}
if (config.engineConfig !== undefined) {
walkVariables(config.engineConfig, "config.engineConfig", new WeakSet());
validateEngineConfigSnapshot(config.engineConfig);
}
return config;