[autofix] xiaohongshu/search: COMMAND_EXEC MutationObserver TypeError when document.body is null
[autofix] xiaohongshu/search: COMMAND_EXEC MutationObserver TypeError when document.body is null
Summary
Local autofix repair verified — retry passes the crash stage after this patch.
Adapter
- Site:
xiaohongshu - Command:
xiaohongshu/search(clis/xiaohongshu/search.js) - OpenCLI version:
1.8.8
Failure
COMMAND_EXEC: Xiaohongshu search failed: TypeError: Failed to execute 'observe' on
'MutationObserver': parameter 1 is not of type 'Node'.
at <anonymous>:18:14
at new Promise (<anonymous>)
at <anonymous>:1:1Reproduces consistently since ~2026-09-13 evenings (UTC+8), across all keywords,
even with default args. Trace <anonymous>:18 maps to WAIT_FOR_CONTENT_JS
line observer.observe(document.body, { childList: true, subtree: true }) —
document.body is null at evaluation time because the xiaohongshu search_result
page now performs an extra client-side redirect before committing a body, so the
evaluate lands in a document where only documentElement exists.
Note the same script already null-guards document.body?.innerText in detect()
two lines above — only the observe() target lacks the guard.
Local fix
Guard both MutationObserver targets with a fallback (document.body || documentElement),
search.js lines 39 and 598:
observer.observe(document.body || document.documentElement, { childList: true, subtree: true });A subtree observer on documentElement fires when <body> is inserted, so
content detection resumes normally. Also raised the content-wait ceiling from 5s
to 20s, which absorbs the extra redirect hop on slower sessions. Output shape
unchanged.
Related: #2470 (umbrella), #2445 (filter ambiguous_option — separate root cause, same command).
Issue filed by OpenCLI autofix after a verified local repair.
Source: jackwener/OpenCLI