fix(sdk): instrument Playwright lifecycle failures - #940
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| Filename | Overview |
|---|---|
| packages/notte-sdk/src/notte_sdk/endpoints/sessions.py | Adds comprehensive Playwright lifecycle snapshots and listeners, but emits complete browser URLs into application logs without redaction. |
| tests/sdk/test_session_playwright_dialog_policy.py | Extends unit coverage for sync and async lifecycle listener registration and emitted diagnostic events. |
Prompt To Fix All With AI
### Issue 1
packages/notte-sdk/src/notte_sdk/endpoints/sessions.py:713
**Lifecycle logs expose URL credentials**
When an SDK consumer visits an OAuth callback, signed URL, password-reset link, or another credential-bearing URL, `_playwright_page_state` copies the complete query string and fragment into lifecycle log messages, exposing tokens and signatures to application log readers and collection systems.
**How this was verified:** The full `page.url` flows into the state dictionary interpolated by `_log_playwright_event`, and the configured stderr logger applies no URL redaction.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "fix(sdk): instrument Playwright lifecycl..." | Re-trigger Greptile
| def _playwright_page_state(page: Any) -> dict[str, Any]: | ||
| state: dict[str, Any] = {"page_id": _playwright_object_id(page)} | ||
| try: | ||
| state["url"] = page.url |
There was a problem hiding this comment.
Lifecycle logs expose URL credentials
When an SDK consumer visits an OAuth callback, signed URL, password-reset link, or another credential-bearing URL, _playwright_page_state copies the complete query string and fragment into lifecycle log messages, exposing tokens and signatures to application log readers and collection systems.
How this was verified: The full page.url flows into the state dictionary interpolated by _log_playwright_event, and the configured stderr logger applies no URL redaction.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/notte-sdk/src/notte_sdk/endpoints/sessions.py
Line: 713
Comment:
**Lifecycle logs expose URL credentials**
When an SDK consumer visits an OAuth callback, signed URL, password-reset link, or another credential-bearing URL, `_playwright_page_state` copies the complete query string and fragment into lifecycle log messages, exposing tokens and signatures to application log readers and collection systems.
**How this was verified:** The full `page.url` flows into the state dictionary interpolated by `_log_playwright_event`, and the configured stderr logger applies no URL redaction.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Context
Several production SDK consumers received Playwright
TargetClosedErrorwhile the corresponding Notte browser sessions and browser-worker pods remained alive. The current SDK caches the first Playwright page indefinitely, which leaves too little evidence to distinguish a page replacement or detach from a context close or a full CDP disconnect.Changes
Emitted events
sdk_playwright_connectedsdk_playwright_page_createdsdk_playwright_page_closedsdk_playwright_page_crashedsdk_playwright_context_closedsdk_playwright_browser_disconnectedsdk_playwright_cached_page_unhealthysdk_playwright_session_stop_requestedValidation
uv run ruff format packages/notte-sdk/src/notte_sdk/endpoints/sessions.py tests/sdk/test_session_playwright_dialog_policy.pyuv run ruff check packages/notte-sdk/src/notte_sdk/endpoints/sessions.py tests/sdk/test_session_playwright_dialog_policy.pyuv run pytest tests/sdk/test_session_playwright_dialog_policy.py tests/sdk/test_session_context_close_reason.py -q(8 passed)git diff --checkNeed help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.