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: stop a corrupt null remoteMedia marker from 500ing the retry route (#4683)

[._.]/ Adam Eivy1642ca90c251
diff --git a/server/routes/mediaJobs.js b/server/routes/mediaJobs.js
index c5c6e1fc7b..b3a97f933f 100644
--- a/server/routes/mediaJobs.js
+++ b/server/routes/mediaJobs.js
@@ -263,7 +263,7 @@ router.post('/:id/retry', asyncHandler(async (req, res) => {
{ status: 409, code: 'JOB_RETRY_TEMP_UPLOAD' },
);
}
- const body = validateRequest(retryBodySchema, req.body ?? {}) ?? {};
+ const body = validateRequest(retryBodySchema, req.body ?? {});
const rawOverrides = body.params ?? {};
// A `effort: 'default'` override is a clear-to-default signal, not a value to
// merge — handled by deleting params.effort below so the render falls back to
@@ -307,8 +307,12 @@ router.post('/:id/retry', asyncHandler(async (req, res) => {
// recover; it must submit rather than skip preflight.
// Cleared here, not in routedJobParams — boot restoration re-enqueues an
// interrupted job under its ORIGINAL id and needs `reconcile: true` kept.
+ // `?? {}` because the predicate gates on PRESENCE, not truthiness — a
+ // hand-edited or peer-merged `remoteMedia: null` passes it, and this is the
+ // one marker consumer that would hard-crash rather than fail closed in the
+ // kind's remote module the way every other one does.
if (isRemoteMediaJob({ kind: job.kind, params })) {
- const { cancelRequested: _canceled, reconcile: _reconcile, ...marker } = params.remoteMedia;
+ const { cancelRequested: _canceled, reconcile: _reconcile, ...marker } = params.remoteMedia ?? {};
params.remoteMedia = { ...marker, cancelRequested: false, reconcile: false };
}
const result = enqueueJob({ kind: job.kind, params, owner: job.owner });
diff --git a/server/routes/mediaJobs.test.js b/server/routes/mediaJobs.test.js
index 783bad5301..0c9018a8cb 100644
--- a/server/routes/mediaJobs.test.js
+++ b/server/routes/mediaJobs.test.js
@@ -221,6 +221,21 @@ describe('mediaJobs routes', () => {
expect(params.remoteMedia.request.prompt).toBe('a lighthouse at dusk');
});
+ it('POST /:id/retry survives a corrupt null marker instead of 500ing', async () => {
+ // `isRemoteMediaJob` gates on presence, not truthiness — a hand-edited
+ // media-jobs.json (or a peer-merged record) can hold `remoteMedia: null`
+ // and still be classified as routed. The queue's remote module is where a
+ // malformed marker fails closed; the retry route must not crash first.
+ jobStore.set('j-null-marker', {
+ id: 'j-null-marker', kind: 'image', owner: null, status: 'failed',
+ params: { prompt: '', modelId: null, remoteMedia: null },
+ });
+ const r = await request(makeApp()).post('/api/media-jobs/j-null-marker/retry').send({});
+ expect(r.status).toBe(200);
+ const { params } = stubs.enqueueJob.mock.calls[0][0];
+ expect(params.remoteMedia).toEqual({ cancelRequested: false, reconcile: false });
+ });
+
it('POST /:id/retry leaves a local job\'s params alone', async () => {
// Bypass probe for the marker reset above: a training job carrying a stray
// marker has no federated contract, so it must keep the local path.