chatboxai/chatbox · error · Error
mineru_api_token_required
Error message
mineru_api_token_required
What it means
Thrown in the 'mineru' case of the parser switch when parserConfig.mineru?.apiToken is falsy. The MinerU parser type was selected but no API token is configured, so the call cannot proceed. It is thrown before parseFileWithMineruService is invoked, so no network call is attempted.
Source
Thrown at src/renderer/stores/sessionHelpers.ts:657
switch (parserConfig.type) {
case 'none': {
throw new Error('document_parser_not_configured')
}
case 'local': {
result = await parseFileWithLocalFallback(file, uniqKey)
break
}
case 'chatbox-ai': {
result = await parseFileWithLocalFallback(file, uniqKey, { forceChatboxAIFallback: true })
break
}
case 'mineru': {
const apiToken = parserConfig.mineru?.apiToken
if (!apiToken) {
throw new Error('mineru_api_token_required')
}
try {
result = await parseFileWithMineruService(file, uniqKey, apiToken)
} catch (error) {
log.error(`MinerU parsing failed for "${file.name}":`, error)
if (
error instanceof Error &&
(error.message === EMPTY_ATTACHMENT_CONTENT_ERROR || error.message.startsWith('third_party_parser'))
) {
throw error
}
throw new Error('third_party_parser_failed')
}
break
}
default: {
throw new Error('document_parser_not_configured')View on GitHub (pinned to 81571269ad)
Solutions
- Open Settings → Document Parser → MinerU and paste a valid MinerU API token (obtain one from the MinerU dashboard), then re-attach the file.
- Validate the token field is non-empty before allowing the 'mineru' option to be saved — surface a field error in the UI rather than throwing at parse time.
- If you cannot obtain a MinerU token, switch the parser to 'local' or 'chatbox-ai' which do not require one.
- After a config migration, run a repair step that re-maps any stale token field name to parserConfig.mineru.apiToken.
Example fix
// before
const apiToken = parserConfig.mineru?.apiToken
if (!apiToken) {
throw new Error('mineru_api_token_required')
}
// after — trim and give a clearer, actionable error
const apiToken = parserConfig.mineru?.apiToken?.trim()
if (!apiToken) {
throw new Error('mineru_api_token_required: set it in Settings → Document Parser → MinerU')
} Defensive patterns
Strategy: validation
Validate before calling
// Validate the MinerU token before allowing the parser to be saved/used.
function mineruTokenIsSet(cfg: DocumentParserConfig): boolean {
return Boolean(cfg.mineru?.apiToken && cfg.mineru.apiToken.trim().length > 0)
}
if (cfg.type === 'mineru' && !mineruTokenIsSet(cfg)) {
// block save or surface a field error
} Type guard
function hasMineruToken(cfg: unknown): cfg is { type:'mineru'; mineru: { apiToken: string } } {
return typeof cfg === 'object' && cfg !== null &&
(cfg as any).type === 'mineru' &&
typeof (cfg as any).mineru?.apiToken === 'string' &&
(cfg as any).mineru.apiToken.trim().length > 0
} Try / catch
try {
await preprocessFile(file)
} catch (e) {
if (e instanceof Error && e.message === 'mineru_api_token_required') {
openSettings('documentParser.mineru.apiToken')
return
}
throw e
} Prevention
- Make the MinerU token field required (UI validation) when type === 'mineru'.
- Trim whitespace on save; reject empty/whitespace tokens at the settings layer.
- Run a config-repair pass on version upgrades to remap any renamed token field to mineru.apiToken.
When it happens
Trigger: getEffectiveDocumentParserConfig() returns { type:'mineru', mineru: { apiToken: undefined | '' } }. The destructured apiToken is falsy and the guard throws immediately.
Common situations: User selected MinerU in the parser dropdown but never entered an API token; token was cleared by a settings reset; token stored under a different key than parserConfig.mineru.apiToken after a config-schema migration; user pasted only whitespace.
Related errors
- third_party_parser_not_supported_in_chat
- document_parser_not_configured
- Custom provider "${providerId}" conflicts with a builtin pro
- Unknown transport type
- Unsupported search provider: ${provider}
AI-assisted analysis of chatboxai/chatbox@81571269ad (2026-08-12).
Data as JSON: /api/errors/3274674f6daf1279.
Report an issue: GitHub.