browser-search icon indicating copy to clipboard operation
browser-search copied to clipboard

smart-extract --expr returns {"ok":true} as content when the expression evaluates to undefined

Open Johell1NS opened this issue 1 month ago • 1 comments

Problem

When the JS expression passed to smart-extract.mjs --expr (or to camofox.mjs evaluate / tab evaluate) evaluates to undefined (for example a selector that matches nothing, document.querySelector('h1')?.textContent on a page without an <h1>), the Camofox server omits the result field from its JSON response.

camofox.mjs then falls back to res?.result ?? res, so the whole response envelope {"ok":true} is returned as the "result". smart-extract treats it as valid content and reports ok: true with content: "{"ok":true}".

Expected

An expression that yields no value should be treated as empty, so smart-extract tries the camofox-tab path and then reports the URL as failed (or escalates to CloakBrowser if every URL fails), instead of returning a bogus success.

Fix

In scripts/camofox/camofox.mjs (cmdEvaluate and tab evaluate) replace res?.result ?? res with res?.result ?? null.

Notes

Pre-existing behavior, not related to any Camofox version. Verified against Camofox 1.18.1.

Johell1NS avatar Oct 21 '26 09:10 Johell1NS

Released in v3.2.0.

Johell1NS avatar Oct 21 '26 12:10 Johell1NS