Skip to content

fix: show the real cause when browser cookies can't be read - #144

Merged
vanloctech merged 1 commit into
mainfrom
fix/cookie-access-errors
Nov 13, 2026
Merged

vanloctech merged 1 commit into
mainfrom
fix/cookie-access-errors

Conversation

@vanloctech

Copy link
Copy Markdown
Owner

Summary

Users with cookies from browser enabled kept getting the "Cookie Access Failed — Chrome is currently open" dialog, even after closing Chrome. The logs showed a different error:

ERROR: could not find chrome cookies database in ".../Google/Chrome/Profile 3"

yt-dlp prints this both when the profile is missing and when the OS refuses to list the folder. The second case is what happened here: macOS privacy protection (TCC) blocked reading Chrome's data after an OS update, and yt-dlp's directory walk silently found nothing. The frontend matched this with a broad regex (cookie.*database|failed to.*cookie|…) meant for the Windows "database locked" case. As a result it showed the "close your browser" dialog, which could never help.

Changes

Backend

  • New error codes YT_COOKIE_ACCESS_DENIED and YT_COOKIE_PROFILE_NOT_FOUND.
  • classify_missing_cookie_db() reads the path from yt-dlp's message and probes the profile folder and its parent:
    • PermissionDenied → access denied (macOS: Full Disk Access needed)
    • otherwise → profile not found
  • Used in both build_download_error_message (download path) and parse_ytdlp_error. infer_error_code maps the message to profile-not-found when no path check is possible.
  • YT_COOKIE_DB_LOCKED still covers only the real "could not copy … cookie database" case.

Frontend

  • New src/lib/cookie-errors.ts chooses the dialog by error code. Only Windows lock and DPAPI/App-Bound failures are still matched by message. The broad regex is gone from DownloadContext and UniversalContext.
  • BrowserCookieErrorDialog has three variants, and all its text now goes through i18n:
    • Blocked: on macOS the primary button opens Full Disk Access settings (reuses open_macos_privacy_settings). The steps mention that dev builds need the terminal app to have the permission. Other systems get generic permission guidance.
    • Profile not found: the primary button opens settings to pick another profile. The steps include chrome://version.
    • Locked: the previous Windows guidance.
  • backend-error.ts has the new codes as non-retryable, plus message inference.
  • i18n for all 13 locales (common.cookieErrorDialog and the two backendErrors). Changelog in EN/VI/ZH-CN, and docs/backend-error-codes.md.

Notes for reviewers

  • macOS attributes TCC permissions to the responsible app. For tauri dev that is the terminal/IDE that started it, not target/debug/youwee, which is ad-hoc signed and changes on every rebuild. The dialog text covers this case.

Test plan

  • Biome, tsc, bun tests (118, including new tests/cookie-errors.test.ts) and cargo check pass (pre-commit hook)
  • cargo test passes (238), with new tests for blocked parent/profile folders, missing profile, unrelated errors, message-only inference, and the download error path
  • Ran the classifier on the real blocked path on macOS: it returns YT_COOKIE_ACCESS_DENIED
  • Manual (macOS): the dialog showed the access-denied variant. After granting Full Disk Access to the responsible app and restarting, the download succeeded
  • Manual (Windows): a locked Chromium cookie database still shows the "browser is open" variant

🤖 Generated with Claude Code

yt-dlp prints "could not find <browser> cookies database" both when the
profile is missing and when the OS refuses to list the folder (macOS
privacy protection after an update). A broad frontend regex matched
"cookie ... database" and showed the "Chrome is currently open" dialog,
so closing the browser never helped.

- New error codes YT_COOKIE_ACCESS_DENIED and
  YT_COOKIE_PROFILE_NOT_FOUND. The backend probes the profile folder
  from the error path to tell a blocked folder from a missing profile,
  in both the download path and parse_ytdlp_error.
- The frontend picks the dialog by error code; only Windows lock and
  DPAPI/App-Bound failures still match by message.
- BrowserCookieErrorDialog has three variants: blocked (macOS opens the
  Full Disk Access settings), missing profile (opens settings to pick a
  profile) and locked. All text is translated in 13 locales.
- Tests for the classification, changelog entries, error code docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T11:31:06.670039Z 610d73c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 610d73c325

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/lib/cookie-errors.ts

// Only the Windows lock / decryption failures. Keep this narrow: a broad "cookie … database"
// match used to show the "browser is open" dialog for unrelated errors such as a missing profile.
const DB_LOCKED_PATTERN = /could not copy.*cookie|failed to decrypt.*dpapi|app.bound.encryption/i;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Route explicit cookie permission failures to access denied

If yt-dlp reports an explicit Permission denied ... cookies error instead of the could not find ... cookies database form classified by the backend, the error reaches this helper as a generic error and returns null. The previous callers recognized permission-denied cookie messages, so these failures now skip the dedicated access-denied guidance; add a narrow permission-denied mapping.

Useful? React with 👍 / 👎.

@vanloctech
vanloctech merged commit 0265829 into main Nov 13, 2026
4 checks passed
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