Add open_viewer to NotteSession.__init__#790
Conversation
NotteSession.__init__ passes all **data kwargs to SessionStartRequest.model_validate(), but open_viewer is not a field of SessionStartRequest. This causes a Pydantic ValidationError when examples like cli_agent.py and quickstart.py call notte.Session(open_viewer=...). Add open_viewer as an explicit keyword parameter (matching RemoteSession.__init__) so it is consumed before **data reaches model_validate().
|
| Filename | Overview |
|---|---|
| packages/notte-browser/src/notte_browser/session.py | Adds open_viewer: bool = False to NotteSession.__init__ signature so it is consumed before **data reaches SessionStartRequest.model_validate(), matching the pattern already used in RemoteSession. |
| tests/test_session.py | Adds a parametrized regression test (test_open_viewer_does_not_raise_validation_error) for both open_viewer=True and open_viewer=False, addressing the previously noted missing test coverage for this bug fix. |
Reviews (2): Last reviewed commit: "test: add regression test for open_viewe..." | Re-trigger Greptile
| persona: BasePersona | None = None, | ||
| window: BrowserWindow | None = None, | ||
| keep_alive: bool = False, | ||
| open_viewer: bool = False, |
There was a problem hiding this comment.
No test added for this bug fix
This PR fixes a real bug (ValidationError when passing open_viewer to a local session) but adds no unit or integration test. Per the repository's test guidelines, at least one integration test is required for every bug fix. A minimal test that constructs NotteSession(open_viewer=True) or NotteSession(open_viewer=False) and verifies no ValidationError is raised would cover this path and prevent regression.
Context Used: # Test guidelines
- Add a comment if the PR does n... (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/notte-browser/src/notte_browser/session.py
Line: 132
Comment:
**No test added for this bug fix**
This PR fixes a real bug (`ValidationError` when passing `open_viewer` to a local session) but adds no unit or integration test. Per the repository's test guidelines, at least one integration test is required for every bug fix. A minimal test that constructs `NotteSession(open_viewer=True)` or `NotteSession(open_viewer=False)` and verifies no `ValidationError` is raised would cover this path and prevent regression.
**Context Used:** # Test guidelines
- Add a comment if the PR does n... ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Added a parametrized regression test (test_open_viewer_does_not_raise_validation_error) that constructs NotteSession(open_viewer=True) and NotteSession(open_viewer=False), verifying no ValidationError is raised. CI is green.
Verify that NotteSession(open_viewer=True/False) does not raise a Pydantic ValidationError, covering the fix from the previous commit.
Summary
notte.Session(open_viewer=...)raisesValidationError: Extra inputs are not permittedfor local sessions becauseopen_vieweris not a field ofSessionStartRequest. This addsopen_viewer: bool = Falseas an explicit keyword parameter toNotteSession.__init__(matchingRemoteSession.__init__) so it is consumed before**datais passed toSessionStartRequest.model_validate().test_root_level_scripts[cli_agent.py]andtest_root_level_scripts[quickstart.py]which both callnotte.Session(open_viewer=open_viewer).Details
RemoteSession.__init__already handlesopen_vieweras an explicit parameter.NotteSession.__init__was missing it, so the kwarg leaked into**dataand caused Pydantic to reject it. The fix is a single line addition to the function signature.Insight: open_viewer breaks local Session in nightly examples
Note
Created by Mendral. Tag @mendral-app with feedback or questions.