Skip to content

feat: open URL inputs with protocol options and headers - #14

Merged
shimonewman merged 1 commit into
mainfrom
feat/input-options
Nov 21, 2026
Merged

shimonewman merged 1 commit into
mainfrom
feat/input-options

Conversation

@shimonewman

Copy link
Copy Markdown
Collaborator

What

Adapters take two new optional constructor arguments, placed before every URL input on the ffmpeg and ffprobe command lines:

  • options: protocol options by ffmpeg's own names, for example ['request_size' => 1048576, 'multiple_requests' => 1].
  • headers: request headers, for a source that wants a credential the URL cannot carry.
$encoder = new Encoder(
    new FFmpeg(options: $options, headers: $headers),
    new FFprobe(options: $options, headers: $headers),
);

Why

ffmpeg asks an HTTP source for everything from an offset to the end of the file. A source that answers in bounded pieces needs to be asked for pieces (request_size), and one behind an API key needs a header. The Appwrite videos worker needs both to read encrypted uploads through the Storage download endpoint.

Behaviour

  • A local file is opened without the options or headers. ffmpeg 8.1.2 exits with an error when given -request_size for a file input.
  • Option names, option values and header names are validated; a header value with a control character is rejected, and the message does not echo the value.
  • Headers are treated as a secret: the command a Runtime exception reports carries *** in place of the -headers value.
  • Both default to empty, which keeps current behaviour.

Tests

  • Unit: the arguments appear for a URL and not for a local path, follow the whitelists, and bad names or values are rejected.
  • E2E (RemoteTest): every range the test server logs is no larger than request_size; a guarded URL is only readable with its header; a failed command does not report the header value.
  • Full suite: 602 tests pass locally in the repo's Docker image (ffmpeg 8.1.2). pint and phpstan are clean.

Release

Needs a 0.0.7 tag after merge. appwrite/appwrite pins this branch until then.

🤖 Generated with Claude Code

Adapters take optional options and headers, placed before every URL
input on the ffmpeg and ffprobe command lines. A local file is opened
without them, since ffmpeg refuses a protocol option it has no use for.
Header values are a credential, so the command a failure reports
carries a mask in their place.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@appwrite

appwrite Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Code review

Commit Status Tier Verdict Details
1fdaa6f Reviewed Reviewed 🔵 A · Mergeable after minor fixes 💬 Commented View review

The only issue is a credential leak in error diagnostics on the less common DEBUG-level failure path.

Adds protocol options and custom request headers to remote FFmpeg and FFprobe inputs, while leaving local-file inputs unchanged. It also masks the -headers argument in reported commands and adds unit/E2E coverage plus README guidance.

Note

Not approving while a bug finding is open: Redact headers from captured error output too

Findings (1)
Finding Where
🟡 Redact headers from captured error output too src/Video/Process.php:194
Fix with agent prompt
### Issue 1
src/Video/Process.php:194
**Redact headers from captured error output too**

At `DEBUG`, libavformat can write its serialized HTTP request, including custom headers, to stderr. This passes that tail unchanged into `Runtime::output()`, so a failed request can expose the credential even though `command()` is masked; redact header values in captured diagnostics too.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Walkthrough (8)
File Change
README.md Documents configuring protocol options and headers for URL inputs.
src/Video/Adapter.php Validates and stores options/headers, applying them only to remote inputs.
src/Video/Adapter/FFmpeg.php Passes each input path to the shared input-option builder.
src/Video/Adapter/FFprobe.php Passes the probed path to the shared input-option builder.
src/Video/Process.php Masks the headers argument in process commands reported on failure.
tests/Video/E2E/RemoteTest.php Covers ranged URL reads, guarded requests, and command header masking.
tests/Video/E2E/serve.php Adds a guarded URL fixture that requires an X-Guard header.
tests/Video/Unit/AdapterTest.php Tests remote/local argument construction and input option/header validation.

Reviewed 1fdaa6f

Tip

Comment @appwrite review to re-run, or mention @appwrite with a question.

@shimonewman
shimonewman merged commit ddf124e into main Nov 21, 2026
6 of 7 checks passed

@appwrite appwrite Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Tier A · See the inline comments. Summary

Comment thread src/Video/Process.php
throw new Runtime(
'Command "'.$command[0].'" failed with exit code '.$status,
$command,
self::masked($command),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redact headers from captured error output too

At DEBUG, libavformat can write its serialized HTTP request, including custom headers, to stderr. This passes that tail unchanged into Runtime::output(), so a failed request can expose the credential even though command() is masked; redact header values in captured diagnostics too.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Video/Process.php
Line: 194

Comment:
**Redact headers from captured error output too**

At `DEBUG`, libavformat can write its serialized HTTP request, including custom headers, to stderr. This passes that tail unchanged into `Runtime::output()`, so a failed request can expose the credential even though `command()` is masked; redact header values in captured diagnostics too.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

🟡 Minor · security · Reply if this doesn't apply.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant