-
Notifications
You must be signed in to change notification settings - Fork 184
Raise on evaluate_js failure instead of returning a null DataSpace #905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
11472f5
Raise on evaluate_js failure instead of returning a null DataSpace
giordano-lucas be1dbab
Gate raise_on_failure on failure, not on an exception having been thrown
giordano-lucas 1f8a1fe
Document raise_on_failure's actual default
giordano-lucas f80671f
Test the read five deployed Functions actually died on
giordano-lucas 3893100
Synthesize the failure exception before the result is built
giordano-lucas 2f9f4c1
Merge main (structured exception detail on ExecutionResult)
giordano-lucas 94c42e5
Drop generic-message sniffing now that the wire carries typed errors
giordano-lucas 0bb6904
Add end-to-end test for the structured exception wire
giordano-lucas 44cb7bf
Check documented session-config defaults against the SDK
giordano-lucas c09f88f
Opt callers with their own failure contracts out of the raise gate
giordano-lucas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| #!/usr/bin/env python3 | ||
| """Check documented session-config defaults against the SDK's actual values. | ||
|
|
||
| `docs/src/features/sessions/configuration.mdx` is hand-written, so its | ||
| `<ParamField default={...}>` values can silently drift from the code (the page | ||
| said `raise_on_failure` defaults to false for seven months while the config | ||
| said true). This check compares every documented default against the source of | ||
| truth: `SessionStartRequest` field defaults and `notte_core` config values. | ||
|
|
||
| Doc param names do not always match field names one-to-one, so the mapping in | ||
| `code_defaults()` is explicit; a documented default with no mapping entry is an | ||
| error, which forces the mapping to grow with the page. | ||
|
|
||
| Run from the repo root (the script needs the workspace venv for notte imports): | ||
| uv run python docs/src/scripts/check_config_docs_defaults.py | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import re | ||
| import sys | ||
| from enum import Enum | ||
| from pathlib import Path | ||
| from typing import Any | ||
|
|
||
| REPO_ROOT = Path(__file__).resolve().parents[3] | ||
| CONFIGURATION_MDX = REPO_ROOT / "docs" / "src" / "features" / "sessions" / "configuration.mdx" | ||
|
|
||
| PARAM_FIELD_RE = re.compile(r'<ParamField\s+path="([^"]+)"[^>]*?\sdefault=(\{[^}]*\}|"[^"]*")') | ||
|
|
||
|
|
||
| def code_defaults() -> dict[str, Any]: | ||
| from notte_core.common.config import config | ||
| from notte_sdk.types import ( | ||
| DEFAULT_HEADLESS_VIEWPORT_HEIGHT, | ||
| DEFAULT_HEADLESS_VIEWPORT_WIDTH, | ||
| SessionStartRequest, | ||
| ) | ||
|
|
||
| fields = SessionStartRequest.model_fields | ||
|
|
||
| def field_default(name: str) -> Any: | ||
| return fields[name].default | ||
|
|
||
| return { | ||
| "headless": field_default("headless"), | ||
| "solve_captchas": field_default("solve_captchas"), | ||
| "proxies": field_default("proxies"), | ||
| # the docs param is the SDK's idle timeout | ||
| "timeout_minutes": field_default("idle_timeout_minutes"), | ||
| # the request fields default to None ("server decides"); the effective | ||
| # server defaults are these shared constants | ||
| "viewport_width": DEFAULT_HEADLESS_VIEWPORT_WIDTH, | ||
| "viewport_height": DEFAULT_HEADLESS_VIEWPORT_HEIGHT, | ||
| "browser_type": field_default("browser_type"), | ||
| "use_file_storage": field_default("use_file_storage"), | ||
| "perception_type": config.perception_type, | ||
| "raise_on_failure": config.raise_on_session_execution_failure, | ||
| } | ||
|
|
||
|
|
||
| def parse_doc_default(token: str) -> Any: | ||
| """Turn a ParamField default token (`{true}`, `{3}`, `{"chrome"}`, `"fast"`) into a value.""" | ||
| if token.startswith('"'): | ||
| return token[1:-1] | ||
| inner = token[1:-1].strip() | ||
| if inner == "true": | ||
| return True | ||
| if inner == "false": | ||
| return False | ||
| if inner.startswith('"') and inner.endswith('"'): | ||
| return inner[1:-1] | ||
| try: | ||
| return int(inner) | ||
| except ValueError: | ||
| return inner | ||
|
|
||
|
|
||
| def normalize(value: Any) -> Any: | ||
| if isinstance(value, Enum): | ||
| return value.value | ||
| return value | ||
|
|
||
|
|
||
| def main() -> int: | ||
| text = CONFIGURATION_MDX.read_text() | ||
| expected = code_defaults() | ||
| errors: list[str] = [] | ||
| checked = 0 | ||
|
|
||
| for match in PARAM_FIELD_RE.finditer(text): | ||
| name, token = match.group(1), match.group(2) | ||
| doc_value = parse_doc_default(token) | ||
| if name not in expected: | ||
| errors.append( | ||
| f"{name}: documented default {doc_value!r} has no entry in code_defaults(); " | ||
| "add a mapping to the code's source of truth" | ||
| ) | ||
| continue | ||
| checked += 1 | ||
| code_value = normalize(expected[name]) | ||
| if doc_value != code_value or isinstance(doc_value, bool) is not isinstance(code_value, bool): | ||
| errors.append(f"{name}: docs say {doc_value!r}, code default is {code_value!r}") | ||
|
|
||
| if checked == 0: | ||
| errors.append(f"no ParamField defaults found in {CONFIGURATION_MDX}; the regex or the page drifted") | ||
|
|
||
| if errors: | ||
| print(f"{CONFIGURATION_MDX.relative_to(REPO_ROOT)} disagrees with the SDK defaults:") | ||
| for error in errors: | ||
| print(f" - {error}") | ||
| return 1 | ||
|
|
||
| print(f"checked {checked} documented defaults against the SDK: all match") | ||
| return 0 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| sys.exit(main()) |
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Synthesize return-style failures before the immediate raise gate.
When
config.raise_conditionisRaiseCondition.IMMEDIATELY, the gate at Line [849] seesexception is Nonefor controller, tool, and JavaScript failures that only setsuccess=False. This block runs afterward, so the method records the failed result and attempts the post-action screenshot before raising. Move failure synthesis before the immediate gate while preservingraise_on_failure=Falseas an opt-out.🤖 Prompt for AI Agents