{"record":{"id":"f7e138bfb2f0b6c0","repo":"alyssaxuu/screenity","slug":"missing-sceneid-in-uploadmeta","errorCode":null,"errorMessage":"Missing sceneId in uploadMeta","messagePattern":"Missing sceneId in uploadMeta","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/pages/CloudRecorder/CloudRecorder.jsx","lineNumber":6079,"sourceCode":"      \"multiSceneCount\",\n      \"multiLastSceneId\",\n      \"activeSceneId\",\n      \"recordingToScene\",\n      \"recordedTabDomain\",\n      \"recordingType\",\n    ]);\n\n    const { cameraFlipped } = await chrome.storage.local.get([\"cameraFlipped\"]);\n\n    let insertAfterSceneId = null;\n    if (multiMode) {\n      insertAfterSceneId = multiLastSceneId || activeSceneId;\n    } else {\n      insertAfterSceneId = activeSceneId;\n    }\n\n    if (!uploadMeta.sceneId) {\n      throw new Error(\"Missing sceneId in uploadMeta\");\n    }\n\n    if (!uploadMeta.screen?.mediaId && !uploadMeta.camera?.mediaId) {\n      throw new Error(\n        \"No valid media uploaded - both screen and camera mediaId are missing\",\n      );\n    }\n\n    const sceneId = uploadMeta.sceneId;\n    const existingStatus = await getSceneCreateStatus(sceneId);\n    let sceneOutcome = null;\n    let shouldIncrementMultiSceneCount = false;\n\n    if (existingStatus?.status === \"created\") {\n      logDebugEvent(\"scene-create-skip\", {\n        projectId,\n        sceneId,\n      });","sourceCodeStart":6061,"sourceCodeEnd":6097,"githubUrl":"https://github.com/alyssaxuu/screenity/blob/512606387b8d07dda5e63bb428bd063f0a2a3ed0/src/pages/CloudRecorder/CloudRecorder.jsx#L6061-L6097","documentation":"When finalizing a cloud recording, the upload metadata must reference the scene the media belongs to. CloudRecorder throws this error when uploadMeta.sceneId is falsy before it calls getSceneCreateStatus, because subsequent scene-creation/status calls cannot proceed without a scene identifier.","triggerScenarios":"Recording completes and onUploadFinished builds uploadMeta without a sceneId — e.g. recording started before any scene existed, scene creation request failed silently, or activeSceneId/insertAfterSceneId resolved to undefined at stop time.","commonSituations":"User starts recording immediately on a fresh project before the initial scene is created; scene-creation API call failed at record start but recording continued; state lost after a service-worker or page restart mid-recording; multi-scene logic (multiLastSceneId/activeSceneId) both undefined.","solutions":["Validate at recording start: do not begin capture until a sceneId exists (create a scene eagerly if none).","Ensure the scene-creation call at recorder init is awaited and its errors surfaced/retried so activeSceneId is always populated.","When building uploadMeta in the upload-finished callback, pass the sceneId explicitly from the recording session state instead of relying on possibly-empty activeSceneId.","Wrap the finalize path so this error cancels/rolls back the recording session with a clear user message rather than leaving orphaned uploads.","Check for page refreshes/state resets during recording that clear activeSceneId; persist it alongside the recording session."],"exampleFix":"// before\nif (!uploadMeta.sceneId) {\n  throw new Error(\"Missing sceneId in uploadMeta\");\n}\n// after\nif (!uploadMeta.sceneId) {\n  uploadMeta.sceneId = await ensureSceneExists({ projectId, insertAfterSceneId });\n}","handlingStrategy":"validation","validationCode":"if (!uploadMeta?.sceneId) {\n  throw new Error(\"Refusing to finalize: uploadMeta.sceneId is not set\");\n}","typeGuard":"function hasSceneId(meta) {\n  return typeof meta?.sceneId === \"string\" && meta.sceneId.length > 0;\n}","tryCatchPattern":"try {\n  await finalizeUpload(uploadMeta);\n} catch (err) {\n  if (err.message === \"Missing sceneId in uploadMeta\") {\n    const scene = await createScene({ projectId });\n    await finalizeUpload({ ...uploadMeta, sceneId: scene.id });\n  } else {\n    throw err;\n  }\n}","preventionTips":["Create the initial scene before allowing recording to start","Always await and error-check the scene-creation call at recorder init","Persist activeSceneId with the recording session to survive refreshes/restarts","Pass sceneId explicitly through the upload-finished callback instead of reading mutable state"],"tags":["validation","missing-parameter","cloud-recorder","state"],"backgroundTag":"missing-required-argument","analyzedSha":"512606387b8d07dda5e63bb428bd063f0a2a3ed0","analyzedAt":"2026-09-02T20:59:09.419Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}