jackwener/OpenCLI · error · CommandExecutionError

Boss chatlist returned an unexpected response

Error message

Boss chatlist returned an unexpected response

What it means

In auto mode, after handling the array case and the IDENTITY_MISMATCH_CODE case, any other non-conforming response shape from fetchFriendList that survives assertOk leads to this CommandExecutionError. It means the recruiter chat API returned a structured response the adapter cannot interpret — neither a friend array, nor a known mismatch code, nor a recognized ok response.

Source

Thrown at clis/boss/chatlist.js:114

        const bossResult = await fetchFriendList(page, {
            pageNum,
            jobId: kwargs['job-id'] || '0',
            allowNonZero: true,
        });
        if (Array.isArray(bossResult)) {
            if (bossResult.length === 0)
                throw new EmptyResultError('boss chatlist', 'No recruiter-side chat sessions were returned.');
            return bossResult.slice(0, limit).map(mapBossRow);
        }
        if (bossResult.code === IDENTITY_MISMATCH_CODE) {
            await navigateToGeekChat(page);
            const rows = await buildGeekRows(page, limit);
            if (rows.length === 0)
                throw new EmptyResultError('boss chatlist', 'No job-seeker-side chat sessions were returned.');
            return rows;
        }
        assertOk(bossResult);
        throw new CommandExecutionError('Boss chatlist returned an unexpected response');
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Log the raw bossResult (add a temporary console.log before the throw) to see the actual code/payload
  2. Update clis/boss/utils.js fetchFriendList/assertOk to recognize the new response code or envelope
  3. Re-authenticate (boss login) in case the response is a disguised auth denial
  4. Retry later if it is a rate-limit/anti-bot response, ideally with a different IP or slower polling

Example fix

// before
assertOk(bossResult);
throw new CommandExecutionError('Boss chatlist returned an unexpected response');
// after
assertOk(bossResult);
console.error('bossResult', JSON.stringify(bossResult));
if (bossResult.code === NEW_RATE_LIMIT_CODE) return [];
throw new CommandExecutionError('Boss chatlist returned an unexpected response');
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-flight: verify session and that the chat API is reachable
const identity = await bossVerify(page); // throws early on auth problems
// then run chatlist expecting a known shape

Type guard

function isKnownBossResult(v) {
  if (Array.isArray(v)) return true;
  if (v === null || typeof v !== 'object') return false;
  return typeof v.code === 'number' || v.ok === true;
}

Try / catch

try {
  rows = await bossChatlist({ side: 'auto' });
} catch (err) {
  if (err instanceof CommandExecutionError && err.message.includes('unexpected response')) {
    // unknown API envelope: capture payload for the adapter maintainers
    console.error('boss chatlist contract drift; raw result not exposed — inspect clis/boss/utils.js');
    return []; // degrade gracefully in pipelines
  }
  throw err;
}

Prevention

When it happens

Trigger: fetchFriendList returns an object whose code is not IDENTITY_MISMATCH_CODE and which assertOk does not accept (unknown error code, new API envelope, {code:0} shape change, or a wrapped {data:...} without ok flag).

Common situations: zhipin.com changed its friend-list API response envelope; a new business error code appeared (rate limit, permission change); the anti-bot layer returned a JSON denial the adapter doesn't classify; adapter/utils.js out of date relative to the live API.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/b1f0382da807d78a. Report an issue: GitHub.