Skip to content

test(proxy): harden transcript-proxy guard against two silent bypasses (hardens #1129) - #1131

Closed
groupthinking wants to merge 3 commits into
mainfrom
claude/determined-maxwell-4k7sox
Closed

test(proxy): harden transcript-proxy guard against two silent bypasses (hardens #1129)#1131
groupthinking wants to merge 3 commits into
mainfrom
claude/determined-maxwell-4k7sox

Conversation

@groupthinking

@groupthinking groupthinking commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Canonical issue

Closes #1087 (via the same fix as #1129 — see Agent handoff below).

Outcome

Strengthens the AST regression guard introduced by #1129 so it can no longer
pass a YouTubeTranscriptApi(...) construction that would still egress outside
the centralized outbound proxy. This branch is fix/centralized-transcript-proxy-1087's
HEAD (5659f2b) plus one test-only commit; the production fix is unchanged.

Scope

  • Included: two test-only hardenings in tests/unit/test_transcript_proxy_coverage.py:
    1. _has_required_keyword no longer treats **kwargs-only calls as compliant —
      YouTubeTranscriptApi(**opts) reads as opaque but egresses directly whenever
      opts omits proxy_config. It now requires an explicit proxy_config= keyword.
    2. test_module_resolves_proxy_config_from_the_canonical_helper now inspects each
      construction's proxy_config AST value and requires it to be a call to
      get_transcript_proxy_config(). Previously a substring/import check let
      proxy_config=<foreign config> or proxy_config=object() pass.
  • Explicitly excluded: no production/source changes; no reformatting of unrelated lines.

Risk

  • Risk level: low
  • Failure mode: test-only. The two tightenings add zero false positives — all 14
    live constructions in src/ pass proxy_config=get_transcript_proxy_config() explicitly.
  • Rollback: revert the single commit 1ba9cd4.

Verification

All at head 1ba9cd4666c1339c7c3001cafba21f8180639fb4.

  • Focused tests — pytest tests/unit/test_transcript_proxy_coverage.py21 passed.
  • Mutation-verified the hardenings are not vacuous:
    • a YouTubeTranscriptApi(**opts) bypass now fails test_every_transcript_client_passes_proxy_config (previously passed);
    • a proxy_config=object() construction now fails test_module_resolves_proxy_config_from_the_canonical_helper (previously passed).
  • ruff check clean; black --check clean on the changed file.
  • Required CI — will run on this PR.
  • Review threads resolved — the two Copilot findings on fix: route every transcript client through the centralized proxy (#1087) #1129 are addressed by this diff.

Production evidence

Not applicable — test-only change. The production behaviour and its evidence are
carried by #1129 (Vercel green, CodeRabbit approved).

Agent handoff


Generated by Claude Code

groupthinking and others added 3 commits July 31, 2026 01:08
youtube-transcript-api >=1.0 only honours a proxy when a ``proxy_config``
is passed to the constructor. Six call sites across four modules built a
bare ``YouTubeTranscriptApi()``, so they egressed from the host's own IP
and bypassed WEBSHARE_PROXY_URL entirely — including
``_extract_transcript_with_rotation``, whose name implies the opposite.

- src/integration/youtube_api.py:99
- src/agents/process_video_with_mcp.py:222,233
- src/agents/interactive_metadata_extractor.py:87
- src/mcp/mcp_video_processor.py:694,718

Each now resolves its config from the canonical
``youtube_extension.utils.proxy.get_transcript_proxy_config`` helper,
guarded by the import fallback this repo already uses in
gemini_video_master_agent.py so modules stay importable outside the
package. The helper returns None when no proxy is configured, so direct
connections keep working unchanged.

Adds tests/unit/test_transcript_proxy_coverage.py: an AST walk over src/
and shared/ that fails if any construction omits proxy_config, plus a
canary that fails if the scan ever matches nothing (the vacuity mode that
has bitten this repo repeatedly).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…roxy

Review on #1129 found the guarded-import fallback introduced by this branch
was itself a silent bypass: when a module is executed by path (the documented
CLI entry point) youtube_extension is not importable, so the stub returned
None and proxy_config=get_transcript_proxy_config() egressed directly from
the host IP -- the exact failure this issue exists to prevent.

Replace the stub in all four standalone-executable modules with a sys.path
bootstrap to the repository's src directory, falling back to a hard
ImportError. The proxy is now either honoured or the module refuses to load;
it is never silently skipped.

Harden the guard suite against three ways it could pass while protecting
less than it claims:
- a missing configured source root was skipped silently
- SOURCE_ROOTS could be narrowed by hand with every other test still green;
  the required roots are now rediscovered from the tree
- referencing the helper was satisfied by the call site alone, so a broken
  import passed; every import from the proxy module must now bind the helper

All 9 mutations kill their tests, including one that revealed a newly added
test was itself vacuous (it asserted parents[1] from a test-side constant
rather than the index the source actually uses).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Closes the two residual holes the automated review flagged on the guard
added by #1129 — both were ways a construction could pass the guard while
still egressing outside the centralized proxy:

1. `**kwargs`-only calls were treated as compliant. `YouTubeTranscriptApi(
   **opts)` reads as opaque but egresses directly whenever `opts` omits
   `proxy_config` — the exact silent bypass this guard exists to catch.
   `_has_required_keyword` now requires an explicit `proxy_config=` keyword.
   No real call site uses `**kwargs`, so this adds zero false positives.

2. `test_module_resolves_proxy_config_from_the_canonical_helper` only checked
   that the helper name appeared in the source and was imported; a call passing
   `proxy_config=<foreign config>` or `proxy_config=object()` still passed. It
   now inspects each construction's `proxy_config` AST value and requires it to
   be a call to `get_transcript_proxy_config()`, subsuming the old literal-None
   check.

Both tightenings are mutation-verified: a `**kwargs` bypass and a
`proxy_config=object()` construction each now fail the guard where they
previously passed. All 21 tests green against the real (14/14 compliant)
call sites.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NaRe39Fsrq2tv8vpn2aRdp
@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
v0-uvai Ready Ready Preview, v0 Jul 31, 2026 7:28am

@github-actions

Copy link
Copy Markdown

🔍 PR Validation

⚠️ Large PR detected (559 lines changed)

@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA 1ba9cd4.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

Scanned Files

None

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

Agent Completion Truth Gate: BLOCKED

Reasons: invalid_payload

Machine-readable verdict
{
  "details": {
    "collection_errors": [
      "incomplete_linked_issue_contract",
      "linked_issue_not_agent_task",
      "missing_intent_snapshot",
      "missing_agent_run_id",
      "missing_agent_login"
    ],
    "invalid_fields": [
      "policy.agent_login",
      "policy.run_id"
    ]
  },
  "reasons": [
    "invalid_payload"
  ],
  "verdict": "blocked"
}

Workflow evidence

Copy link
Copy Markdown
Owner Author

Blocker: Agent Completion Truth Gate — and why I'm not forcing past it

agent-completion/truth-gate/pr-1131 is failing (invalid_payloadpolicy.agent_login, policy.run_id; earlier missing_trusted_publication). This is expected, not a code defect:

  • The change is on a claude/… branch, so the gate classifies it as agent-authored and requires a filled agent-lock manifest backed by a trusted publication (a real agent run_id + published head_sha event). The canonical PR this supersedes, fix: route every transcript client through the centralized proxy (#1087) #1129, passed the gate as not_applicable because its fix/… branch isn't agent-classified.
  • I'm an unattended session with no trusted run_id to publish. I will not fabricate agent_login/run_id to green a truth gate — that would defeat exactly the control it exists to enforce. So per drive-to-green, I'm reporting the blocker rather than gaming it.

The change itself is sound and test-only

Two hardenings to the regression guard from #1129, closing the two residual holes the Copilot review flagged (commit 1ba9cd4):

  1. _has_required_keyword no longer accepts **kwargs-only calls — an explicit proxy_config= is required.
  2. test_module_resolves_proxy_config_from_the_canonical_helper now inspects each construction's proxy_config AST value and requires a call to get_transcript_proxy_config() (previously a substring/import check let proxy_config=object() through).

Both are mutation-verified (a **kwargs bypass and a proxy_config=object() construction each now fail the guard where they previously passed); pytest21 passed; ruff/black clean.

Recommended human action

This branch is a strict superset of #1129 (its HEAD 5659f2b + one test commit). Don't merge both. Cleanest path:

Merging to protected main is a human decision; I've deliberately not auto-merged anything.


Generated by Claude Code

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • [‘architecture-gap’, ‘bug’, ‘ci-cd’, ‘ci/cd’, ‘copilot-rabbit’, ‘documentation’, ‘duplicate’, ‘enhancement’, ‘frontend’, ‘github_actions’, ‘good first issue’, ‘help wanted’, ‘high-priority’, ‘invalid’, ‘javascript’, ‘ml-model’, ‘needs-triage’, ‘pipeline-critical’, ‘placeholder-code’, ‘priority:high’, ‘python’, ‘python:uv’, ‘question’, ‘styling’, ‘tests’, ‘v0’]

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository YAML (base), Repository UI (inherited), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 43f652a4-a06a-4a49-aa13-55fc6a07402a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@groupthinking groupthinking added the duplicate This issue or pull request already exists label Jul 31, 2026 — with ChatGPT Codex Connector

Copy link
Copy Markdown
Owner Author

Contained as a duplicate of canonical #1129. The exact two-part test-only hardening from 1ba9cd4 was transferred to canonical branch fix/centralized-transcript-proxy-1087 at commit 49e887c; the resulting test blob is identical (da6871e5ed13f06afac08b71da7f6089d1936c62). No production changes from this duplicate were needed. The branch is preserved.

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

Labels

duplicate This issue or pull request already exists python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate YouTube transcript client to v1.x with proxy support

2 participants