Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (codex): reject music-video i2v when the reference frame can't be resolved

[._.]/ Adam Eivy3d2da0ea8e9d
diff --git a/server/routes/videoGen.js b/server/routes/videoGen.js
index 92699c0d52..beafed64d2 100644
--- a/server/routes/videoGen.js
+++ b/server/routes/videoGen.js
@@ -687,6 +687,19 @@ router.post('/', frameImageUpload, asyncHandler(async (req, res) => {
} else if (body.sourceImageFile) {
sourceImagePath = resolveGalleryImage(body.sourceImageFile);
}
+ // Music Video director-board renders are always i2v FROM the scene's reference
+ // frame (#1760 Phase 1). resolveGalleryImage returns null for a missing/invalid
+ // gallery file (mustExist defaults true), and an unresolved source would
+ // otherwise fall through to a text-to-video render — silently attaching a clip
+ // that ignores the frame the director chose. Reject instead, so a stale/deleted
+ // reference frame surfaces as a clear error rather than a wrong-looking clip.
+ if (body.musicVideo && !sourceImagePath) {
+ await cleanupAllStaged();
+ throw new ServerError(
+ 'Music Video scene render needs a resolvable reference frame (sourceImageFile) — the scene\'s frame is missing or could not be resolved.',
+ { status: 400, code: 'MUSIC_VIDEO_SOURCE_REQUIRED' },
+ );
+ }
if (uploads.lastImage) {
lastImagePath = await stageUploadDurable(uploads.lastImage, 'last');
extraUploadedTempPaths.push(lastImagePath);
diff --git a/server/routes/videoGen.test.js b/server/routes/videoGen.test.js
index 7b44dc63ef..1bc3f22cd2 100644
--- a/server/routes/videoGen.test.js
+++ b/server/routes/videoGen.test.js
@@ -121,6 +121,7 @@ vi.mock('fs/promises', () => ({
import * as videoGenService from '../services/videoGen/local.js';
import * as mediaJobQueue from '../services/mediaJobQueue/index.js';
+import { resolveGalleryImage } from '../lib/fileUtils.js';
import videoGenRoutes, { isAudioMime } from './videoGen.js';
// isAudioMime is the gating function inside the fileFilter callback. The
@@ -335,6 +336,37 @@ describe('videoGen routes', () => {
}));
});
+ it('forwards a musicVideo i2v tag into job.params alongside the resolved frame (#1760 Phase 1)', async () => {
+ const r = await request(app).post('/api/video-gen/').send({
+ prompt: 'slow dolly across the skyline',
+ mode: 'image',
+ sourceImageFile: 'scene-frame.png',
+ musicVideo: JSON.stringify({ projectId: 'mv-1', sceneId: 'mvs-1' }),
+ });
+ expect(r.status).toBe(200);
+ expect(mediaJobQueue.enqueueJob).toHaveBeenCalledWith(expect.objectContaining({
+ kind: 'video',
+ params: expect.objectContaining({
+ sourceImagePath: '/mock/images/scene-frame.png',
+ musicVideo: { projectId: 'mv-1', sceneId: 'mvs-1' },
+ }),
+ }));
+ });
+
+ it('rejects a musicVideo i2v render when the reference frame cannot be resolved (no silent t2v)', async () => {
+ // A stale/deleted gallery file resolves to null (mustExist defaults true).
+ resolveGalleryImage.mockReturnValueOnce(null);
+ const r = await request(app).post('/api/video-gen/').send({
+ prompt: 'slow dolly across the skyline',
+ mode: 'image',
+ sourceImageFile: 'gone.png',
+ musicVideo: JSON.stringify({ projectId: 'mv-1', sceneId: 'mvs-1' }),
+ });
+ expect(r.status).toBe(400);
+ expect(r.body.code).toBe('MUSIC_VIDEO_SOURCE_REQUIRED');
+ expect(mediaJobQueue.enqueueJob).not.toHaveBeenCalled();
+ });
+
it('forwards lastImageFile + mode for FFLF', async () => {
const r = await request(app).post('/api/video-gen/').send({
prompt: 'morph between two scenes',