Skip to content

fix(rendering): handle 0-byte audio segment files gracefully in Audio::new and SegmentRecordings (#2069) - #2073

Closed
Samarth1306w wants to merge 2 commits into
CapSoftware:mainfrom
Samarth1306w:fix/studio-mode-empty-audio-segment-2069
Closed

fix(rendering): handle 0-byte audio segment files gracefully in Audio::new and SegmentRecordings (#2069)#2073
Samarth1306w wants to merge 2 commits into
CapSoftware:mainfrom
Samarth1306w:fix/studio-mode-empty-audio-segment-2069

Conversation

@Samarth1306w

@Samarth1306w Samarth1306w commented Aug 4, 2026

Copy link
Copy Markdown

Issue

Closes #2069

Summary

Fixes editor opening failure (Unable to Open Recording — segment 0 / mic / Failed to open audio: End of file) when recording bundles contain empty 0-byte audio segment files (audio-input.ogg size = 0).

Changes

  1. Updated Audio::new in crates/rendering/src/project_recordings.rs to check std::fs::metadata(path).len() == 0 and return an explicit error (Audio file is 0 bytes (empty)).
  2. Added graceful fallback handling in SegmentRecordings for mic audio loading errors (matching system_audio), logging a warning and treating as None so visual video and camera tracks remain fully readable and editable.

Acceptance criteria

  • Checks metadata.len() == 0 before invoking ffmpeg::format::input
  • Treats 0-byte mic audio segment files gracefully without crashing recording view
  • Allows display and camera video playback even if mic audio segment is 0 bytes

/claim #2069

Greptile Summary

The PR makes recording metadata loading tolerate empty or unreadable microphone segments so projects can still open with their video tracks. It also adds per-IP rate limiting to public analytics and guest-checkout endpoints and introduces a unit test checking that declared rate-limit identifiers are referenced.

  • Rejects zero-byte audio before invoking FFmpeg.
  • Degrades microphone loading failures to an absent audio track for single- and multi-segment recordings.
  • Adds rate limits to analytics tracking and guest checkout.
  • Adds a source-level contract test for rate-limit identifiers.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete changed-code defects identified.

The audio fallback preserves video accessibility for invalid microphone tracks, while the new public-route rate limits follow the existing fail-open per-IP implementation.

Important Files Changed

Filename Overview
crates/rendering/src/project_recordings.rs Detects zero-byte audio and gracefully omits microphone tracks when audio metadata loading fails; no concrete regression was established.
apps/web/app/api/analytics/track/route.ts Adds fail-open, per-IP rate limiting before analytics payload parsing.
apps/web/app/api/settings/billing/guest-checkout/route.ts Adds fail-open, per-IP rate limiting before creating guest Stripe checkout sessions.
apps/web/tests/unit/rate-limit-ids.test.ts Adds a unit test scanning web TypeScript sources for references to every declared rate-limit identifier.

Reviews (1): Last reviewed commit: "fix(rendering): handle 0-byte audio segm..." | Re-trigger Greptile

Context used:

@superagent-security

Copy link
Copy Markdown

🚨 Contributor flagged. Click here for more info: Superagent Dashboard

@richiemcilroy

Copy link
Copy Markdown
Member

Thanks for taking a shot at this. Closing it after investigating #2069 in depth, for a few reasons:

  1. The investigation showed the recording-side bug described in Studio mode + camera on macOS: every audio-input.ogg is 0 bytes; editor fails with "Failed to open audio: End of file" #2069 cannot occur (details in the issue), so the "Closes Studio mode + camera on macOS: every audio-input.ogg is 0 bytes; editor fails with "Failed to open audio: End of file" #2069" framing does not hold. The genuine defect is only the editor-side open failure.
  2. The mic fallback idea is right, but this diff moves the mic load above the system-audio load. ensure_start_time is stateful: the first track examined seeds the start-time expectation for the segment, so reordering can turn a currently recoverable mismatch on legacy bundles into a hard display / Missing start time failure. It also ships without tests or verification, and the 0-byte pre-check in Audio::new is redundant since FFmpeg already errors on empty files.
  3. The rate-limiting changes to the analytics and guest-checkout routes are unrelated to this issue and touch a payment path, so they need their own PR and review. Feel free to resubmit those separately.

The editor-side fix landed via #2075, which preserves the existing load order and adds regression tests for the encoder path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Studio mode + camera on macOS: every audio-input.ogg is 0 bytes; editor fails with "Failed to open audio: End of file"

3 participants