Repository navigation
download_audio: delegate the link-to-audio policy to yb (#122) - #126
Merged
Merged
Conversation
download_audio is now a thin caller of yb.download.download_audio_bounded: braidio keeps the credential pre-check and the error classification, and supplies its SSRF check (_docs._validate_target) and its env-tunable caps. yb owns the target check (now also on the resolved page URL), the playlist/live/duration refusal, the pinned caps, mp3, the per-call result directory, and the copyright notice. Floor yb[download]>=0.1.24. Tests: the download tests fake yb's yt-dlp calls (not the policy), so the credential-reaches-both-calls and cap-survives-merge guards run the real policy; the SSRF test goes through the server and matches the refusal's own words (a direct call raised "no caller identity", a ToolError too). Closes #122 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er guards From the adversarial review of #126: a raw yt-dlp ValueError (bot gate text) skipped classification, so every failure now goes through as_tool_error; cookies_file=False so yb's own default jar cannot masquerade as 'never provisioned'; tests stop patching yb internals, add a cookie-jar pre-check guard, and assert only the per-call dir is removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #122
download_audiobecomes a thin caller ofyb.download.download_audio_bounded(reeleehq/yb#48, released in yb 0.1.24):creds.check()(before the network) and_media.as_tool_error(bot gate / expiry / unavailable classification).creds.optsasextra_opts(yb restricts it toDEPLOYMENT_OPT_KEYS),_docs._validate_targetasvalidate_target, andBRAIDIO_AUDIO_MAX_BYTES/BRAIDIO_AUDIO_MAX_DURATION_Sas the caps.result.path, then removesresult.path.parent(in afinally, so a failed ingest does not leak the file), and carriesresult.noticeascopyright_notice.yb[download]>=0.1.24.Behaviour changes a caller could notice: the over-long-source message is yb's wording (
exceeds the 2700s limit), and playlists and live streams are now refused explicitly.Tests. The download tests now fake yb's two yt-dlp calls rather than the policy, so the guards that credentials reach both calls and that the cap survives the merge run the real
download_audio_bounded. The SSRF test goes through the server and matches the refusal's own wording. Called directly, the tool raisedno caller identity, which is also aToolError, so the bareraises(ToolError)would have passed without the URL ever being checked. Mutations checked: droppingvalidate_target=fails the SSRF test, and dropping the directory cleanup fails two tests.No deploy coupling beyond the usual: the connector picks this up on its next platform deploy, and its venv must resolve yb >= 0.1.24.
Adversarial review (fresh Opus subagent)
Verdict: MERGE-AFTER-FIXES. The fixes are applied in the second commit.
except ValueErrorbranch reported a raw yt-dlpValueError(bot-gate text included) without classifying it. The branch is removed, so every failure now goes throughas_tool_error. Guarded by the bot-gate test, which raises the error as bothRuntimeErrorandValueError.cookies_file=False. Before, yb could fall back to its own default jar, and a bot gate on that jar read as "never provisioned"._extract_info/download_youtube_video. yb's own tests pin the caps.creds.check()had no tool-level guard, and that gap predates this PR.parent.parent, which is the shared download directory, now fails.creds.check()now runs before the address check, so a loopback URL on a server with expired cookies gets the cookie error. Neither path makes a network call.🤖 Generated with Claude Code