Repository navigation
feat(recording): connection-only recording target, downloads and upload outcome - #543
Conversation
…ad outcome Lets an instance that stores recordings only in a storage connection create a recording output, list and download its recordings, and see why an upload failed (issue #534): - POST /api/v1/outputs accepts a recording output when MINIO_* is configured or its connectionId names an existing connection with a default bucket; otherwise 400 naming both options. POST and PATCH reject an unknown connectionId with 400 "Storage connection not found". - The recordings routes return stored recordings without MINIO_* env; 503 is kept for a database failure only. - Activation snapshots the recording's upload target on the production (recording: { outputId, connectionId?, startedAt }); deactivate uploads to it instead of re-reading output assignments. - Deactivate stores lastRecordingUpload (uploaded count, failed files, the connection used, and a reason) on the production. - RecordingDoc.durationMs is read from the MP4 header at upload; startedAt falls back to the activation start. - Each recording gets a downloadUrl (presigned GET with a signed response-content-disposition: attachment) and, when it cannot be signed, playbackUnavailable with the reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
PR Review: feat(recording): connection-only recording target, downloads and upload outcome (#543)
Verdict: REQUEST CHANGES
Prior findings
This PR has no earlier reviews or comments. The only comment on #534 is the triage note, and it raises no findings. The rows below are the issue's "What to change" items and acceptance criteria, checked against head 28cd019.
| # | Finding / criterion | Status | Evidence |
|---|---|---|---|
| Item 1 / AC1 | Recording output accepted with a connection and no MINIO_*; without a target, 400 names both options |
FIXED | 28cd019 src/routes/outputs.ts:86-104, :244-247; outputs-recording-target.test.ts:78-107 |
| Item 1 / AC2 | Unknown connectionId on POST/PATCH returns 400 "Storage connection not found" and writes nothing |
FIXED | 28cd019 outputs.ts:96-101, :347-350; tests :109, :148 |
| Item 2 / AC3 | Recordings routes return stored docs or [] without the env; a database failure still returns 503 |
OPEN | The 503 gates are gone and /recordings and /recordings/:id are correct. But GET /api/v1/productions/:id/recordings maps any failure of the production lookup to 404 (src/routes/recordings.ts:120-124). See Critical 1 |
| Item 3 / AC4 | Upload target saved at activation and used at deactivate after the output is removed while live | FIXED (code + unit test); the upload to a real C needs live verification |
28cd019 productions.ts:585-601, :322-328; recording-upload-target.test.ts:177 runs a real activate, then removes the output, then deactivates |
| Item 4 / AC5 | lastRecordingUpload (uploaded, failed files, connection, reason) is stored and returned by GET; it holds no secrets |
FIXED (code + unit test); a real 403 bucket and the file staying on Strom need live verification | productions.ts:303-462, :1259, :1283; tests :240, :271, :288 |
| AC6 | Deleting a connection still referenced by an output or recording is refused with 409 | FIXED (regression test) | storage-connections-routes.test.ts (+9 lines) |
| Item 6 / AC7 | downloadUrl with a signed response-content-disposition, same TTL |
FIXED (code + unit test); browser save and Chrome/Safari playback need live verification | recording-uploader.ts:303-318, recordings.ts:44-48, :97-104; recordings-routes-connection-only.test.ts:118 |
| Item 7 / AC8 | playbackUnavailable: "connection-missing" when the connection record is gone |
FIXED | recordings.ts:84-108; test :137 |
| Item 5 / AC9 | durationMs from the MP4 header; startedAt falls back to the activation start |
FIXED (code + unit tests); the "within 1 s of ffprobe" check needs live verification | src/lib/mp4-duration.ts, recording-uploader.ts:455, productions.ts:426; mp4-duration.test.ts |
| AC10 | Unit tests cover items 1, 2, 3, 4, 6, 7 | FIXED, with the AC3 gap noted below | — |
| Q1 (birme) | Keep the 400 when no storage target exists (no disk-only recording) | FIXED | outputs.ts:87-91 |
Critical Issues (must fix before merge)
- AC3 is not met for
GET /api/v1/productions/:id/recordings, and the test that claims it hides the gap. The route first runsawait getDb().get(req.params.id)and sends 404 "Production not found" from a barecatch {}(src/routes/recordings.ts:120-124). The production DB and the recordings DB live on the same CouchDB, so in a real outage this lookup fails first, and the route returns 404, not 503. The PR body says "A database failure still returns 503 on all three routes". The testreturns 503 on a database failure(recordings-routes-connection-only.test.ts:155) passes only because itsdbDownflag failsgetRecordingsDb()and leaves thegetDb()mock working (:28-33). Fix: give the production lookup the same 404-vs-503 split you added to/recordings/:id, which checksstatusCode === 404orDocument type mismatch(ideally as one shared helper, sinceoutputs.ts:96-98repeats it too). Then makedbDownalso failgetDb().get, so the test checks the real failure mode.
Warnings (should fix)
- The legacy fallback has no direct test. A production activated before this change has
recorderBlockIdbut norecordingsnapshot.deactivate-upload-failfast.test.tscovers that shape only with no assignments and an env target. Add one case: norecording, an assigned recording output withconnectionId: 'stconn-C', and an assertion that the upload goes toC. That pins the backward-compatibility path atproductions.ts:325-328. - The #366
_revguard is copied unchanged (productions.ts:386-394) but is not tested at the route level. It is correct: no write to the production happens between the handler's read and the upload, andlastRecordingUploadis only written later throughwriteDeactivatedDoc. Because the code moved, a test should captureisStillRecordingfrom themockUploadRecordingscall args and check that it returnstrueonce the stored_revchanges.
Nits (optional)
failed[].errorinlastRecordingUploadholds up to 200 characters of the S3 error body (recording-uploader.ts:273). There is no secret key in it and no presigned URL, since PUT uses header auth. For some error codes S3 includes<AWSAccessKeyId>or<StringToSign>further into the body, but the 200-character limit cuts that off in practice. That is fine, but the doc comment should mention it.downloadFileNamechanges any extension to.mp4, soa/segment.mkvbecomessegment.mp4. The recorder only writes MP4 today, but non-MP4 files would be saved under the wrong extension.
What Was Verified
- Head
28cd019containsorigin/main(2fc18a0).pnpm install --frozen-lockfile,pnpm run typecheck(0 errors) andnpx vitest run(1336/1336) all pass locally. CIbuild-and-testpasses. - The commit has the co-author trailer and is on a feature branch.
- No fabricated contracts:
DEFAULT_CONNECTION_ID,StorageConnectionNotFoundErrorandresolveStorageTargetexist (src/lib/storage-connection.ts:28,31,85).- The
Document type mismatchmessage matchessrc/db/index.ts:87. activateStromFlownow returnsrecorderOutputId(flow-generator.ts:1100,:1322).
- Presigned URLs:
response-content-dispositionis part of the signed canonical query. It sorts after theX-Amz-*params in byte order, and its value is RFC 3986 encoded.- The filename goes through a
[A-Za-z0-9._-]allow-list, so a crafted key cannot inject into the header. - The TTL matches
playbackUrl. Nothing is stored. A test asserts the secret never appears in the response.
- Credentials:
lastRecordingUploadholds the connection id, bucket, counts, reason and message, but no secret and no URL. The tests atrecording-upload-target.test.ts:238and the routes test at:133assert the decrypted secret is absent. _revguard:uploadProductionRecordingruns before any production write in the deactivate handler.- Activation writes
recordingin the sameupdateProductionDocasstromFlowId, before any deactivate can read it. - The conflict-retry branches of
writeDeactivatedDoccarrylastRecordingUploadthrough without changing their status logic. deactivatedDocclearsrecordingand keeps the previouslastRecordingUploadwhen a deactivate has no recording (test at:314).
- Backward compatibility: a production with no
recordingfalls back tofirstRecordingOutput. A recording doc with noconnectionIdkeeps the default-bucket path, andstartedAtfalls back todoc.updatedAtas before. - MP4 parser: it is bounded. A size-0 box consumes the rest of its container, oversized or 64-bit sizes are rejected, and any exception returns
undefined. It cannot loop forever and cannot read out of bounds.
…utage GET /api/v1/productions/:id/recordings mapped any failure of the production lookup to 404, so a CouchDB outage returned 404 instead of 503. Split not-found from unavailable with a shared isDocNotFoundError helper (also used by /recordings/:id and the output storage check), and make the test's dbDown flag fail the production lookup too. Add tests for the legacy upload-target fallback (no recording snapshot, assigned output on a storage connection) and for the #366 _rev guard passed to uploadRecordings. Document what lastRecordingUpload.failed[].error may contain. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Addressed the REQUEST CHANGES review on 28cd019 in 24b364e. Critical: AC3 on Warning: legacy fallback test. Added. The production has Warning: #366 Nits. I documented what Checks: |
|
daily-backlog-pr Phase 3: new commit |
There was a problem hiding this comment.
PR Review: feat(recording): connection-only recording target, downloads and upload outcome (#543) — re-review
Verdict: APPROVE
Prior findings
Sources read: the REQUEST CHANGES review on 28cd019, the implementer's response comment, the re-review-cycle marker, issue #534 (body, acceptance criteria, triage comment). No human waived or rejected any finding. Judged against head 24b364e.
| # | Finding / criterion | Status | Evidence |
|---|---|---|---|
| Critical 1 / AC3 | GET /api/v1/productions/:id/recordings mapped any production-lookup failure to 404; DB outage must return 503 |
FIXED | 24b364e src/routes/recordings.ts:122-130; helper src/lib/db-errors.ts:12-15; dbDown now also fails getDb().get (recordings-routes-connection-only.test.ts:30-31), 503 test covers all three routes (:157-165) and fails against the 28cd019 route code; new 404 test at :167 |
| Warning 1 | Legacy fallback (no recording snapshot, output on stconn-C) untested |
FIXED | 24b364e recording-upload-target.test.ts:314-336 |
| Warning 2 | #366 _rev guard untested at route level |
FIXED | 24b364e recording-upload-target.test.ts:338-361 |
| Nit 1 | Document what failed[].error may contain |
FIXED | 24b364e src/db/types.ts:431-437 |
| Nit 2 | downloadFileName forces .mp4 |
Not changed (optional nit; recorder only writes MP4) | |
| Item 1 / AC1, AC2 | Connection-only recording output; unknown connectionId → 400 |
FIXED | src/routes/outputs.ts:87-104 |
| Item 2 / AC3 | Recordings routes without env; 503 on DB failure | FIXED | see Critical 1 |
| Item 3 / AC4, Item 4 / AC5 | Upload target snapshot; lastRecordingUpload without secrets |
FIXED (unit tests; live run outstanding) | productions.ts:322-328 |
| AC6 | Referenced connection delete → 409 | FIXED | storage-connections-routes.test.ts |
| Item 6 / AC7, Item 7 / AC8 | downloadUrl with content-disposition; playbackUnavailable |
FIXED | recording-uploader.ts, recordings.ts |
| Item 5 / AC9 | durationMs from MP4 header |
FIXED (unit tests; ffprobe check outstanding) | src/lib/mp4-duration.ts |
| AC10, Q1 | Unit tests; keep the 400 with no target | FIXED | outputs.ts:87-91 |
Critical Issues
None.
Follow-ups (not blocking)
- Live-instance parts of AC4, AC5, AC7, AC9 should be checked on openlivedev after merge.
What Was Verified
- Head contains
origin/main; incremental diff28cd019..24b364e(6 files, +90/-9) scoped to the findings. pnpm install --frozen-lockfile,pnpm run typecheck,pnpm run build,npx vitest run(1339/1339) pass locally; CIbuild-and-testgreen.
A recording output needs a storage target by default (Eyevinn#534, Eyevinn#543). Restore main's 400 for no connection / "default" without MINIO_*, and allow it only when RECORDING_LOCAL_ONLY=true (default off). Document the opt-in, mention the connectionId target in the OpenAPI OutputType, and fix the stale gate reference in guest-calling-provisioning.md. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
* feat(recording): record to Strom's disk without object storage A recording output no longer requires MinIO/S3. Strom's recorder writes segments to its own media path, so object storage only decides whether deactivate uploads them: - POST /api/v1/outputs accepts outputType 'recording' with no MINIO_* set. - Deactivate skips splitNow and the upload when storage is not fully configured, logs where the segments stay, and tears down immediately. - isRecordingEnabled() is renamed isObjectStorageConfigured(); it now gates only the upload target in resolveRecordingUploadTarget. - Startup warns when the MINIO_* set is partial (treated as unset). - README env table and .env.example document the MINIO_*/RECORDING_* vars. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * feat(recording): gate disk-only recording behind RECORDING_LOCAL_ONLY A recording output needs a storage target by default (#534, #543). Restore main's 400 for no connection / "default" without MINIO_*, and allow it only when RECORDING_LOCAL_ONLY=true (default off). Document the opt-in, mention the connectionId target in the OpenAPI OutputType, and fix the stale gate reference in guest-calling-provisioning.md. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com> Co-authored-by: Jonas Birmé <jonas.birme@eyevinn.se>
Summary
recordingoutput can now be created on an instance that stores recordings only in a storage connection (noMINIO_*env). An unknownconnectionIdonPOST/PATCHreturns 400 "Storage connection not found" instead of failing at upload time. With no target at all it still returns 400, and the message names bothMINIO_*and storage connections. Disk-only recording (feat(recording): record to Strom's disk without object storage #404) is still refused, as the issue recommends.MINIO_*is missing. They return the stored recordings, or[]. A database failure still returns 503 on all three routes, includingGET /api/v1/recordings/:id, which used to send every failure to 404.recorderBlockId(recording: { outputId, connectionId?, startedAt }). Deactivate uploads to that saved target, so removing or re-pointing the output while the production is live no longer changes or drops the upload.lastRecordingUploadon the production:finishedAt,outputId,connectionId,bucket,uploaded,failed[{file,error}],reason,message.GET /api/v1/productions/:idreturns it. It contains no secrets and no presigned URLs.durationMs, read from the MP4 header (moov/mvhd, ormvex/mehdfor fragmented files).startedAtstill comes from the file name (fix(recording): date swept segments by their own session's start #407). If the name has no timestamp, it now falls back to the activation start instead ofupdatedAt.downloadUrlnext toplaybackUrl: the same presigned GET and TTL, withresponse-content-disposition=attachment; filename="<basename>.mp4"signed into the query. If neither URL can be signed, the response givesplaybackUnavailablewith a reason:connection-missing,connection-no-bucket,storage-not-configured,bucket-mismatchorsigning-failed.Closes #534
Changes
src/routes/outputs.ts: addedrecordingTargetError().POSTandPATCHuse it to check that the recording output has a storage target and that its connection exists.src/routes/recordings.ts: removed theisRecordingEnabled()503 gates. AddeddownloadUrl, theplaybackUnavailablereasons,downloadFileName(), and 404 vs 503 handling on/recordings/:id.src/routes/productions.ts: activation savesrecording. The upload code that was inline in deactivate moved intouploadProductionRecording(), which returns aRecordingUploadSummary. That summary is written viawriteDeactivatedDoc, so the_revcheck (Delete recordings from Strom after upload #366) is unchanged.src/lib/flow-generator.ts:ActivationResult.recorderOutputId.src/lib/recording-uploader.ts:presignGetUrltakes an optionalcontentDisposition, and uploaded segments carrydurationMs.src/lib/mp4-duration.ts(new): reads the duration from the MP4 box tree. No dependencies.src/db/types.ts:ActiveRecording,RecordingUploadSummary,RecordingUploadReason, andProductionDoc.recording/lastRecordingUpload.docs/specs/vod-recording-minio.md, a note indocs/specs/storage-connections.md, and a new entry indocs/repo-patterns.md.Test Plan
npx vitest run, 132 files and 1336 tests (30 new)outputs-recording-target.test.ts: criteria 1 and 2 (create on a connection with no env, the 400 with no target, unknown connection on POST/PATCH writes nothing, connection with no bucket)recordings-routes-connection-only.test.ts: criteria 3, 7 and 8 ([]instead of 503, 503 on DB failure,downloadUrl,connection-missing)recording-upload-target.test.ts: criteria 4 and 5 (output removed while live still uploads to C;lastRecordingUploadwithauth-error, the failed file andAccessDenied; connection missing; no target)storage-connections-routes.test.ts: criterion 6 regression (deleting a connection still referenced by a recording output returns 409)mp4-duration.test.tsand therecording-leftover-sweep.test.tsaddition:durationMspnpm run typecheckandpnpm run buildpassdownloadUrlsignature (withresponse-content-disposition) matches botocore'sS3SigV4QueryAuthfor the same inputsffprobewithin 1 s)Checklist
Notes for reviewers: these are additive contract changes for open-live-studio#216, #219 and #220. Files that fail to upload stay on Strom for the next sweep, as before. An activation that started before this change has no saved
recording, so its deactivate falls back to reading the current output assignments.🤖 Generated with Claude Code