Skip to content

[NOT-502] fix: add logging to bare except blocks in browser/core packages#803

Open
dashitongzhi wants to merge 5 commits into
nottelabs:mainfrom
dashitongzhi:fix/add-logging-to-bare-except-blocks
Open

[NOT-502] fix: add logging to bare except blocks in browser/core packages#803
dashitongzhi wants to merge 5 commits into
nottelabs:mainfrom
dashitongzhi:fix/add-logging-to-bare-except-blocks

Conversation

@dashitongzhi

@dashitongzhi dashitongzhi commented May 7, 2026

Copy link
Copy Markdown

Summary

Multiple files had bare except Exception: blocks that silently swallowed errors, making it very difficult to diagnose issues in production. This PR adds logger.debug calls with exc_info=True to the most impactful ones.

Linear: NOT-502 https://linear.app/nottelabsinc/issue/NOT-502/notte-pr-803-fix-add-logging-to-bare-except-blocks-in-browsercore

Several files had bare 'except Exception:' blocks that silently swallowed
errors, making debugging difficult. Added logger.debug calls with
exc_info=True to the most impactful ones:

- csspaths.py: log when build_csspath falls back to basic selector
- form_filling.py: log when exact select_option match fails
- observation.py: log JPEG header parsing and PIL image open failures

All use debug level to avoid noise in production while remaining
available for troubleshooting when needed.
Copilot AI review requested due to automatic review settings May 7, 2026 14:08
@greptile-apps

greptile-apps Bot commented May 7, 2026

Copy link
Copy Markdown

PR author is not in the allowed authors list.

@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Added debug logging with exc_info=True at exception handlers in csspaths.py, form_filling.py, and observation.py. The selector-building and select-option fallback paths now record failure details before continuing, and screenshot validation now logs JPEG parsing and image തുറப்பு failures before falling back or returning an empty screenshot. No public APIs or fallback control flow were changed.

Estimated code review effort: 1 (Trivial) | ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding logging to swallowed exceptions in browser/core packages.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Copilot AI 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.

Pull request overview

This PR aims to make previously silent exception paths in the browser/core stack diagnosable by adding debug-level logging when fallbacks are triggered.

Changes:

  • Added debug logs when JPEG header parsing or PIL decoding fails during screenshot validation.
  • Added debug log when exact select_option fails before attempting a case-insensitive fallback.
  • Added debug log when CSS selector construction fails before falling back to a basic selector.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
packages/notte-core/src/notte_core/browser/observation.py Adds debug logs on screenshot parsing/decoding failure paths.
packages/notte-browser/src/notte_browser/form_filling.py Adds debug log when exact select matching fails before fallback logic.
packages/notte-browser/src/notte_browser/dom/csspaths.py Adds debug log when CSS selector construction fails before fallback selector.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return True
except Exception:
except Exception as e:
logger.debug(f"Exact match failed for {field_type} field, trying case-insensitive match: {e}", exc_info=True)
except Exception:
# Fallback to a more basic selector if something goes wrong
except Exception as e:
logger.debug(f"build_csspath failed, falling back to basic selector: {e}", exc_info=True)
Comment on lines +134 to +140
logger.debug("JPEG header parsing failed, falling through to PIL path", exc_info=True)

# Slow path: use PIL for non-JPEG or images that need padding
try:
img = Image.open(io.BytesIO(v))
except Exception:
logger.debug("PIL Image.open failed for screenshot data, returning empty observation screenshot", exc_info=True)
Comment on lines +134 to +140
logger.debug("JPEG header parsing failed, falling through to PIL path", exc_info=True)

# Slow path: use PIL for non-JPEG or images that need padding
try:
img = Image.open(io.BytesIO(v))
except Exception:
logger.debug("PIL Image.open failed for screenshot data, returning empty observation screenshot", exc_info=True)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/notte-browser/src/notte_browser/dom/csspaths.py`:
- Around line 2-4: Import block in csspaths.py is not formatted/sorted per Ruff;
reorder the imports so stdlib imports (import re) come first, then a blank line,
then local/package imports (from notte_core.common.logging import logger), or
simply run the suggested auto-fix command to apply Ruff’s import ordering: ruff
check --fix packages/notte-browser/src/notte_browser/dom/csspaths.py; ensure the
top-level symbols "re" and "logger" are separated into proper import groups with
a blank line between them.

In `@packages/notte-core/src/notte_core/browser/observation.py`:
- Around line 15-16: The import order for nuit_core modules is incorrect: move
the `from notte_core.common.logging import logger` import to its alphabetical
position within the existing `notte_core.*` block (so it appears after `from
notte_core.common.config ...` and before any later `notte_core` imports) to
satisfy Ruff I001; locate the `logger` import in this file (it sits alongside
`from notte_core.actions import ActionUnion`) and reorder it accordingly (or run
`ruff check --fix` on this file to auto-fix).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 91d27433-5424-4d1d-b3e7-e5bf753c06cf

📥 Commits

Reviewing files that changed from the base of the PR and between f7ecf75 and 1af3a36.

📒 Files selected for processing (3)
  • packages/notte-browser/src/notte_browser/dom/csspaths.py
  • packages/notte-browser/src/notte_browser/form_filling.py
  • packages/notte-core/src/notte_core/browser/observation.py

Comment thread packages/notte-browser/src/notte_browser/dom/csspaths.py
Comment thread packages/notte-core/src/notte_core/browser/observation.py Outdated
@2027-evals

2027-evals Bot commented May 7, 2026

Copy link
Copy Markdown

⚠️ Couldn't find a preview deployment for commit 41582b2 after 10 minutes.

2027 auto-runs evals against preview deployments of your docs. To enable this, install one of:

  • Mintlify — if you use Mintlify docs
  • Vercel — for Next.js / static sites
  • Netlify — for most static docs

Once a preview is deployed, open a new PR and we'll run the eval automatically.


Evaluating agent experience using 2027.dev · View dashboard

mendral-app[bot]

This comment was marked as outdated.

Fixes I001 import sorting in csspaths.py and observation.py,
and reformats 3 files to pass pre-commit ruff hooks.

@mendral-app mendral-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Both previous import-sorting issues are fixed in commit 129ff98. The CI failures are all integration tests hitting the staging cluster (HTTP 529 "Cluster is under heavy load" / 502 Bad Gateway) — a pre-existing infrastructure issue tracked in insight #01KP9XGDY6FQENXZ0W8V6QK5H4, not caused by this PR. Code is ready to merge.

Tag @mendral-app with feedback or questions. View session

@giordano-lucas giordano-lucas changed the title fix: add logging to bare except blocks in browser/core packages [NOT-502] fix: add logging to bare except blocks in browser/core packages Jul 14, 2026
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.

2 participants