[codex] Fix YouTube Browser Bridge envelope handling#1730
Open
ppop123 wants to merge 1 commit into
Open
Conversation
0eb9bd2 to
72767db
Compare
72767db to
668caac
Compare
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.
Problem
opencli youtube searchcan return an empty JSON array even when the loaded YouTube results page contains video rows.Example command that reproduced the issue locally:
opencli youtube search "first time in China vlog" --limit 3 --type video -f json --window backgroundBefore this patch the command exited successfully but printed:
Root cause
The YouTube DOM extractor itself was not empty: the page had
window.ytInitialDataandvideoRendererentries. The failure happened at the Browser Bridge boundary.Some Browser Bridge / daemon combinations return
page.evaluate(...)payloads wrapped as:{ "session": "browser:default", "data": [ /* actual evaluate return value */ ] }Several YouTube adapters validated the raw
page.evaluate()result directly, for example withArray.isArray(data)or object checks. With the wrapper present, a valid array looked like a plain object, so commands such asyoutube searchsilently fell through to[]or treated the response as malformed.youtube transcriptalready had its own local unwrapping helper, which is why this was an uneven YouTube-only compatibility gap rather than a totally new pattern.Fix
unwrapBrowserResult()helper inclis/youtube/utils.js.page.evaluate()boundary across YouTube adapters that consume Browser Bridge results:search,comments,feed,history,subscriptionsplaylist,watch-later,video,channellike,unlike,subscribe,unsubscribetranscriptto use the shared YouTube helper instead of keeping a duplicate local function.youtube searchresults and helper behavior.Why scoped to YouTube adapters
This PR does not change the Browser Bridge protocol or globally unwrap
Page.evaluate()results. Many existing adapters already unwrap at their own adapter boundary, and global unwrapping would be a wider compatibility change with more blast radius. The immediate user-visible regression was in YouTube commands, so this keeps the fix narrow and consistent with nearby adapter patterns.Verification
npx vitest run --project adapter clis/youtube/search.test.js clis/youtube/utils.test.js npx vitest run --project adapter clis/youtube npm run typecheck npm run build node dist/src/main.js youtube search "first time in China vlog" --limit 3 --type video -f json --window backgroundThe final live smoke test returned 3 YouTube video rows instead of
[].I also scanned
clis/youtube/*.jsfor non-testpage.evaluatecallers and confirmed they now go throughunwrapBrowserResultwhere applicable.