Skip to content

fix(browser): classify page script errors before keyword matches - #160

Merged
M3gA-Mind merged 1 commit into
tinyhumansai:mainfrom
M3gA-Mind:fix/browser-eval-error-class-first
Oct 23, 2026
Merged

M3gA-Mind merged 1 commit into
tinyhumansai:mainfrom
M3gA-Mind:fix/browser-eval-error-class-first

Conversation

@M3gA-Mind

Copy link
Copy Markdown
Contributor

Summary

reply::classify maps an engine error message to the error a caller acts on, and it ran its substring checks ("timeout", "is not in the allowed domains list", "not visible", …) before the Evaluation error prefix check. An evaluation error carries text the page controls, so a page script that throws TimeoutError: slow came back as a retryable Timeout, and one whose message quotes the allowed-domains refusal came back as BlockedByPolicy. The page could steer the caller's recovery path.

Fix: move the starts_with("evaluation error") check to right after the two stale-ref prefix checks, before any substring match. This is a reorder only; no message the engine produces itself changes class.

Related issue

None.

API or behavior changes

No API change. A page script error now always classifies as PageError, never as Timeout, BlockedByPolicy, NoSuchElement, BrowserUnavailable or InvalidInput.

Validation

Commands actually run, with their outcome:

  • N/A: cargo fmt --all -- --check: rustfmt run on the touched files only; CI runs the full check
  • N/A: cargo clippy --all-targets --all-features -- -D warnings: left to CI
  • N/A: cargo build --all-targets --all-features: left to CI
  • N/A: cargo test --all-features: only the reply tests were run locally (below); CI runs the suite

CARGO_INCREMENTAL=0 cargo test -p tinycomputer-browser --lib -- page_script_error_text_cannot_change engine_messages_map

  • Before the fix: FAILED. 1 passed; 1 failed, with Evaluation error: TimeoutError: slow became Timeout { … }.
  • After the fix (-- reply::): ok. 5 passed; 0 failed.

Tests

New reply_tests::page_script_error_text_cannot_change_the_error_class: five Evaluation error: … messages whose page text matches the timeout, domain-refusal, missing-element, browser-unavailable and invalid-input keywords all classify as PageError. The existing message table is unchanged and still passes.

Documentation

Not needed; a comment at the check says why it comes first.

Checklist

  • The change is focused on one logical change
  • No new #[allow(...)], #[ignore], or relaxed lints
  • No secrets, tokens, or .env contents in the diff or the description

An evaluation error's text comes from the page, so a script that throws
"TimeoutError" or quotes the allowed-domains refusal was classified as a
retryable timeout or a policy block. Check the evaluation-error prefix
right after the stale-ref prefixes, before any substring match.
@coderabbitai

coderabbitai Bot commented Oct 23, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0752ac50-b5d9-4140-96f8-9338b075d889
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@tinysweeper

tinysweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Tiny Sweeper review

Reviewed head: afdf9be26189c16bd48c78730b60e9868fedba22

Verdict: Ready for maintainer review · Priority: none
Coverage: Reviewed 2 of 2 files.
Pull request purpose (title): fix(browser): classi…

Diagnostics and supporting details

Full summary

Pull request purpose (title): fix(browser): classify page script errors before keyword matches. Tiny Sweeper completed its review; deterministic results follow.

Review snapshot

Change surface Files Review signal Count
Production 1 Active findings 0
Tests 1 Noted findings 0
Documentation 0 Resolved findings 0
Configuration 0 Pending checks/questions 0

Completeness: Complete
Test assessment: No supported feature-to-test mapping was available; this does not mean tests are absent or passed.

Features

  • Modified — Evaluation-error prefix check reordered ahead of keyword matches: Page script error text, which the page controls, can no longer steer classification into `Timeout`, `BlockedByPolicy`, `NoSuchElement`, `BrowserUnavailable` or `InvalidInput`; an evaluation error now always classifies as `PageError`. (crates/tinycomputer-browser/src/reply/mod.rs pub(crate) fn classify(message: &str) -> Error {)
  • Added — Comment documenting why the evaluation-error check precedes the keyword branches: Explains in-code that a script error carries page-controlled text, justifying the ordering. (crates/tinycomputer-browser/src/reply/mod.rs pub(crate) fn classify(message: &str) -> Error {)

Tests

No supported feature-to-test mapping was produced. Test execution is not inferred.

Findings

No active actionable findings.

Before merge

None.

Agent review details

critique

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Positive: One finding was retained at no more than Likely confidence: guard the other page-controlled prefix before keyword matches. It is not described as confirmed by an Answered lane and is reported as retained evidence from the critique lane.
  • Lane summary: Critique findings were capped at Likely confidence because retrieval was degraded: Guard the other page-controlled prefix before keyword matches. (1 model finding retained at no more than Likely confidence because retrieval was degraded) _The code index is behind this pull request (indexed at `37cc9f4fbda5`), so retrieved context may be out of date._

security

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: The change moves the `evaluation error` classification ahead of the keyword-based branches in `classify`, so page-controlled text inside a script error can no longer be read as a timeout or a policy refusal; the accompanying test pins that. The reordering is behaviour-preserving for the previously-matched messages (they all start with `Evaluation error` and so were already reaching the `Error::page` branch) and the added test covers exactly the paths the move protects. No defect found in these two files. _The code index is behind this pull request (indexed at `37cc9f4fbda5`), so retrieved context may be out of date._

tests

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: The change moves the `evaluation error` prefix check ahead of the keyword-based branches so page-controlled script text cannot be reclassified as a timeout, policy refusal, or invalid input, and the new test `page_script_error_text_cannot_change_the_error_class` pins exactly that for five payloads that previously would have matched a later branch. Each of those messages fails before the move and passes after it, so the test is a real regression guard rather than a tautology. The remaining branches are untouched, and the existing classification table in `reply_tests.rs` still pins the ordinary messages. No defect found. _The code index is behind this pull request (indexed at `37cc9f4fbda5`), so retrieved context may be out of date._

commits

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: No sensitive content in committed files. _The code index is behind this pull request (indexed at `37cc9f4fbda5`), so retrieved context may be out of date._

description

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Positive: The reorder is described as a faithful, minimal fix: the `starts_with("evaluation error")` check now runs before the keyword substring checks and after the stale-ref prefix checks, which key on engine-generated prefixes the page cannot forge, so page-controlled text can no longer steer classification into `Timeout`, `BlockedByPolicy`, `NoSuchElement`, `BrowserUnavailable` or `InvalidInput`.
  • Lane summary: The reorder is a faithful, minimal fix: the `starts_with("evaluation error")` check now runs before the keyword substring checks (after the two stale-ref prefix checks, which key on engine-generated prefixes the page cannot forge), so page-controlled text can no longer steer classification into `Timeout`, `BlockedByPolicy`, `NoSuchElement`, `BrowserUnavailable` or `InvalidInput`. The new test exercises exactly that, and the pre-existing message table's expectations are unaffected by the move since no engine-generated message begins with "evaluation error". The description matches the diff. _The code index is behind this pull request (indexed at `37cc9f4fbda5`), so retrieved context may be out of date._
Evidence and run details
  • Models: ladder/vectors-oai3, deepseek-v4.1-flash
  • Spend: $0.004418
  • Tokens: 103121 input · 3167 output · 5610 cached · 113 embedding
  • Updated: 2026-10-23T01:49:31Z
Head State Pass summary
afdf9be26189 ready for maintainer review 0 active finding(s), 0 resolved finding(s) (at 2026-10-23T01:49:31Z)

tinysweeper 0.1.2

@tinysweeper tinysweeper 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.

tinysweeper found nothing blocking. Approving.

Diagnostics

Total spend: $0.0044

@M3gA-Mind
M3gA-Mind merged commit 2da2f42 into tinyhumansai:main Oct 23, 2026
32 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant