jackwener/OpenCLI · error · CommandExecutionError
Unexpected HF probe: ${JSON.stringify(probe)}
Error message
Unexpected HF probe: ${JSON.stringify(probe)} What it means
verifyHfIdentity throws this when the whoami probe returns an object that is neither ok nor a recognized kind ('auth'/'http'/'exception'), i.e. an unrecognized probe shape. The message 'Unexpected HF probe: ...' embeds the JSON of the probe for debugging — this guards against HF response-shape drift or probe bugs.
Source
Thrown at clis/hf/auth.js:26
const r = await fetch('/api/whoami-v2', { credentials: 'include', headers: { Accept: 'application/json' } });
if (r.status === 401 || r.status === 403) return { kind: 'auth', detail: 'HF /api/whoami-v2 HTTP ' + r.status };
if (!r.ok) return { kind: 'http', httpStatus: r.status };
const d = await r.json();
if (!d || !d.name || d.type === undefined) return { kind: 'auth', detail: 'HF /api/whoami-v2 has no name — anonymous' };
return { ok: true, username: String(d.name), fullname: String(d.fullname || ''), type: String(d.type || '') };
} catch (e) {
return { kind: 'exception', detail: String(e && e.message || e) };
}
})()`;
async function verifyHfIdentity(page) {
await page.goto('https://huggingface.co/');
await page.wait(1);
const probe = await page.evaluate(WHOAMI_PROBE);
if (probe?.kind === 'auth') throw new AuthRequiredError('huggingface.co', probe.detail);
if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from HF /api/whoami-v2`);
if (probe?.kind === 'exception') throw new CommandExecutionError(`HF whoami failed: ${probe.detail}`);
if (!probe?.ok) throw new CommandExecutionError(`Unexpected HF probe: ${JSON.stringify(probe)}`);
return { username: probe.username, fullname: probe.fullname, type: probe.type };
}
registerSiteAuthCommands({
site: 'hf',
domain: 'huggingface.co',
loginUrl: 'https://huggingface.co/login',
columns: ['username', 'fullname', 'type'],
verify: verifyHfIdentity,
poll: async (page) => {
const probe = await page.evaluate(WHOAMI_PROBE);
if (!probe?.ok) throw new AuthRequiredError('huggingface.co', 'Waiting for Hugging Face login');
return { username: probe.username, fullname: probe.fullname, type: probe.type };
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Inspect the JSON in the message to see the actual probe shape
- Update the opencli package to the latest version compatible with current HF API
- Verify /api/whoami-v2 manually (curl with cookies) to compare its response shape
- Report/patch WHOAMI_PROBE if HF changed field names
Example fix
// before
// outdated probe expects {ok, username, ...}
// after
npm update opencli // pull updated WHOAMI_PROBE matching new HF response shape Defensive patterns
Strategy: try-catch
Validate before calling
const r = await fetch('https://huggingface.co/api/whoami-v2'); const body = await r.json(); if (!body || typeof body.name !== 'string') console.warn('unexpected whoami shape, update CLI'); Type guard
function isKnownProbe(p) { return !!p && ['auth','http','exception'].includes(p.kind) || p?.ok === true; } Try / catch
try { await verifyHfIdentity(page); } catch (e) { if (String(e.message).startsWith('Unexpected HF probe:')) { const probe = JSON.parse(e.message.slice('Unexpected HF probe:'.length)); console.error('unknown probe shape', probe); } else throw e; } Prevention
- Pin/update opencli version matching current HF API
- Log full probe JSON on failure for diagnosis
- Spot-check whoami-v2 response shape after HF announcements
- Wrap probe result parsing defensively
When it happens
Trigger: probe exists but probe.ok is falsy and probe.kind doesn't match any handled branch — e.g. HF's /api/whoami-v2 response shape changed, or the probe returned null/undefined fields after a site update.
Common situations: Hugging Face renamed or restructured whoami-v2 fields; a CLI version outdated relative to the site; the probe script silently produced {ok:false} without a kind.
Related errors
- http
- exception
- Boss friend list response did not include zpData.friendList
- dianping search parser found result cards without shop_id va
- ${command} returned a malformed rows payload
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/3b68cdc1c482b8ff.
Report an issue: GitHub.