mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 04:38:33 +00:00
fix(producer): validate render request engine snapshots
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user