CherryHQ/cherry-studio · error · Error
API Error: ${JSON.stringify(data.error)}
Error message
API Error: ${JSON.stringify(data.error)} What it means
Generic Error thrown by DiDiMcpServer.makeRequest when the upstream returns HTTP 200 but the JSON body contains a truthy 'error' field — a JSON-RPC level error from the DiDi gateway. This means the transport succeeded but the application-level request was rejected (e.g., invalid parameters, business-rule violation, insufficient permissions).
Source
Thrown at src/main/ai/mcp/servers/didiMcp.ts:466
const url = `${this.baseUrl}?key=${this.apiKey}`
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(requestData)
})
if (!response.ok) {
const errorText = await response.text()
throw new Error(`HTTP ${response.status}: ${errorText}`)
}
const data = await response.json()
if (data.error) {
throw new Error(`API Error: ${JSON.stringify(data.error)}`)
}
return data.result
}
}
export default DiDiMcpServer
View on GitHub (pinned to 726446b54c)
Solutions
- Inspect JSON.stringify(data.error) for the upstream error code and message.
- Correct the request parameters based on the upstream error description.
- Verify the API key has access to the requested service/method.
- Handle known business-rule errors gracefully (e.g., no drivers available).
Example fix
// before
if (data.error) {
throw new Error(`API Error: ${JSON.stringify(data.error)}`)
}
// after
if (data.error) {
logger.warn('DiDi API business error', { code: data.error.code, message: data.error.message })
throw new Error(`API Error (${data.error.code}): ${data.error.message ?? JSON.stringify(data.error)}`)
} Defensive patterns
Strategy: try-catch
Validate before calling
// Validate parameters match DiDi API business rules before calling
if (method === 'taxi_create_order' && (!params.departure_latitude || !params.destination_latitude)) {
throw new Error('Departure and destination coordinates are required')
} Try / catch
try {
return await makeRequest(method, params)
} catch (e) {
if (e instanceof Error && e.message.startsWith('API Error:')) {
const errorDetail = JSON.parse(e.message.replace('API Error: ', ''))
// handle known business errors (no drivers, order already cancelled, etc.)
if (errorDetail.code === 'NO_DRIVERS_AVAILABLE') {
return { content: [{ type: 'text', text: 'No drivers available in your area right now.' }] }
}
}
throw e
} Prevention
- Inspect the upstream error code in data.error to handle business-rule rejections.
- Validate semantic parameters (coordinates, order state) before calling.
- Confirm the API key has the required service scope.
When it happens
Trigger: The DiDi API responds with a 200 OK but the body is a JSON-RPC error object. Common with invalid method parameters, unsupported region, disabled service, or business-logic rejections (e.g., no drivers available, order already cancelled).
Common situations: Passing semantically invalid arguments that pass HTTP validation but fail business rules; calling a taxi method in an unsupported city; cancelling an order that is already completed; the API key lacks the required service scope.
Related errors
- Slack API error ${method}: HTTP ${response.status} - ${error
- ${label} returned non-JSON (HTTP ${response.status})
- ${label} failed with HTTP ${response.status}
- HTTP ${response.status}: ${errorText}
- Rerank response results must contain numeric index and relev
AI-assisted analysis of CherryHQ/cherry-studio@726446b54c (2026-08-12).
Data as JSON: /api/errors/775d155ee92be1ac.
Report an issue: GitHub.