{"record":{"id":"b9bbdf3a53eaad05","repo":"jackwener/OpenCLI","slug":"read-hupu-mentions-failed-invalid-browser-respons","errorCode":null,"errorMessage":"Read Hupu mentions failed: invalid browser response","messagePattern":"Read Hupu mentions failed: invalid browser response","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/hupu/mentions.js","lineNumber":131,"sourceCode":"\n          return {\n            ok: true,\n            data: {\n              items: items.slice(0, limit),\n              hasNextPage,\n              pageStr: nextPageStr\n            }\n          };\n        } catch (error) {\n          return {\n            ok: false,\n            error: error instanceof Error ? error.message : String(error)\n          };\n        }\n      })()\n    `);\n        if (!result || typeof result !== 'object') {\n            throw new CommandExecutionError('Read Hupu mentions failed: invalid browser response');\n        }\n        if (result.status === 401 || result.status === 403) {\n            throw new AuthRequiredError('my.hupu.com', 'Read Hupu mentions failed: please log in to Hupu first');\n        }\n        if (!result.ok) {\n            throw new CommandExecutionError(`Read Hupu mentions failed: ${result.error || 'unknown error'}`);\n        }\n        const items = result.data?.items || [];\n        return items.map((item) => {\n            const tid = item.tid ? String(item.tid) : '';\n            const pid = item.pid ? String(item.pid) : '';\n            return {\n                time: item.publishTime || '',\n                username: item.username || '',\n                thread_title: item.threadTitle || '',\n                post_content: stripHtml(item.postContent || ''),\n                quote_content: stripHtml(item.quoteContent || ''),\n                url: tid ? `https://bbs.hupu.com/${tid}.html` : '',","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/hupu/mentions.js#L113-L149","documentation":"The hupu mentions command evaluates an in-page script that fetches the mentions endpoint on my.hupu.com and returns a result object. If the evaluate yields null or a non-object (the script never produced a structured result), the library throws this CommandExecutionError because it cannot even classify success vs auth failure.","triggerScenarios":"page.evaluate in the mentions flow returns undefined/null — the injected async IIFE threw in a way that serialized to nothing, the page navigated away mid-evaluate, or the response could not be parsed into the expected {status, ok, data/error} shape.","commonSituations":"my.hupu.com serving an anti-bot/captcha page so the fetch wrapper is absent; navigation interrupted by a redirect to the login page; Hupu changing the mentions response shape so the script errors before returning; browser context closed.","solutions":["Log in to Hupu first (the sibling AuthRequiredError path only triggers for status 401/403 — a broken page yields this error instead), then retry","Open my.hupu.com/mentions in a browser to confirm the endpoint responds","Retry — transient navigation or network interruptions can yield a null evaluate result","Inspect the injected script in clis/hupu/mentions.js and harden it to always return {status, ok, error} even on internal failure"],"exampleFix":"// before\nif (!result || typeof result !== 'object') {\n  throw new CommandExecutionError('Read Hupu mentions failed: invalid browser response');\n}\n// after (caller-side handling)\ntry { const m = await hupuMentions(page); }\ncatch (e) {\n  if (/invalid browser response/.test(e.message)) await reloadAndLogin(page);\n  else throw e;\n}","handlingStrategy":"try-catch","validationCode":"await page.goto('https://my.hupu.com/');\nif (!page.url().includes('my.hupu.com')) await hupuLogin(page); // redirected to login","typeGuard":"function isValidMentionsResult(r) {\n  return !!r && typeof r === 'object' && typeof r.status === 'number' && typeof r.ok === 'boolean';\n}","tryCatchPattern":"try {\n  const mentions = await hupuMentions(page);\n} catch (e) {\n  if (/invalid browser response/.test(e.message)) {\n    await ensureHupuLogin(page);        // likely auth/captcha page\n    mentions = await hupuMentions(page);\n  } else throw e;\n}","preventionTips":["Confirm an active Hupu login before reading mentions","Check for captcha/anti-bot pages on my.hupu.com before evaluating","Harden the injected script to always return a structured {status, ok} object","Retry once on null evaluate results — often transient navigation races"],"tags":["hupu","browser-automation","invalid-response","mentions"],"backgroundTag":"invalid-browser-response","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}