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

fix: report missing launch video media before publication

[._.]/ Adam Eivy1637c4c93e91
diff --git a/server/routes/apps/launchVideos.js b/server/routes/apps/launchVideos.js
index f36f0713d4..278968b393 100644
--- a/server/routes/apps/launchVideos.js
+++ b/server/routes/apps/launchVideos.js
@@ -21,6 +21,10 @@ const launchVideoTaskSchema = appLaunchVideoRequestSchema
// into an unbounded per-app export.
const LAUNCH_VIDEO_LIST_LIMIT = 50;
const publishTaskSchema = appLaunchVideoPublishSchema.extend(pullRequestProviderOverrideSchema.shape);
+const missingVideoSource = err => {
+ if (err.code === 'ENOENT') throw new ServerError('Launch video file is missing', { status: 404 });
+ throw err;
+};
router.post('/:id/launch-videos/publish', loadApp, asyncHandler(async (req, res) => {
const { videoId, provider, model, effort } = validateRequest(publishTaskSchema, req.body);
@@ -35,12 +39,9 @@ router.post('/:id/launch-videos/publish', loadApp, asyncHandler(async (req, res)
if (!/^[a-zA-Z0-9_-]+\.mp4$/.test(video.filename ?? '')) {
throw new ServerError('Launch video source is invalid', { status: 400 });
}
- const root = await realpath(join(PATHS.data, 'videos'));
- const source = await realpath(join(root, video.filename)).catch(err => {
- if (err.code === 'ENOENT') throw new ServerError('Launch video file is missing', { status: 404 });
- throw err;
- });
- if (dirname(source) !== root || !(await stat(source)).isFile()) {
+ const root = await realpath(join(PATHS.data, 'videos')).catch(missingVideoSource);
+ const source = await realpath(join(root, video.filename)).catch(missingVideoSource);
+ if (dirname(source) !== root || !(await stat(source).catch(missingVideoSource)).isFile()) {
throw new ServerError('Launch video source is invalid', { status: 400 });
}
const cos = await import('../../services/cos.js');
diff --git a/server/routes/apps/launchVideos.test.js b/server/routes/apps/launchVideos.test.js
index 935b57bc68..df8027f05d 100644
--- a/server/routes/apps/launchVideos.test.js
+++ b/server/routes/apps/launchVideos.test.js
@@ -1,5 +1,5 @@
import { afterAll, beforeEach, describe, expect, it, vi } from 'vitest';
-import { mkdir, writeFile, symlink } from 'node:fs/promises';
+import { mkdir, writeFile, symlink, rm } from 'node:fs/promises';
import { join } from 'node:path';
import { cleanupTempDataRoots, lazyTempDataRoot, makePathsProxy } from '../../lib/mockPathsDataRoot.js';
import { PATHS } from '../../lib/fileUtils.js';
@@ -142,6 +142,14 @@ describe('README publication admission', () => {
expect(addTask).not.toHaveBeenCalled();
});
+ it('reports missing media when the entire video directory was removed', async () => {
+ await rm(join(PATHS.data, 'videos'), { recursive: true, force: true });
+ const response = await publish({ videoId: video.id });
+ expect(response.status).toBe(404);
+ expect(response.body.error).toContain('Launch video file is missing');
+ expect(addTask).not.toHaveBeenCalled();
+ });
+
it('does not dispatch when CoS or the repository is unavailable', async () => {
isRunning.mockReturnValue(false);
expect((await publish({ videoId: video.id })).status).toBe(409);