Knowledge Base returning HTML instead of JSON (Une...
# support
k
I’m facing an issue with the Knowledge Base retrieval in my agent and wanted to report it with details. Issue observed When the user asks a simple KB-backed question like: “Where is the clinic located?” the agent triggers the default knowledge base query, but the response fails with the error: Unexpected token '<', '<!DOCTYPE' is not valid JSON Because of this, the assistant falls back to: “I’m not seeing that information here…” even though the information clearly exists in the Knowledge Base. Why the issue is happening and how to solve this .
v
Your server is returning an HTML error page instead of JSON, causing the "Unexpected token '<', '<!DOCTYPE' is not valid JSON" error. To fix this, ensure your endpoint always returns a valid JSON response, even on errors. Here’s a sample Express.js handler:
Copy code
javascript
app.post('/kb/search', async (req, res) => {
  try {
    // Your search logic here
  } catch (error) {
    res.json({ documents: [], error: "Search temporarily unavailable" });
  }
});
This will prevent HTML error pages and ensure your agent receives the expected JSON format. For more details, see the [custom knowledge base documentation](https://docs.vapi.ai/knowledge-base/custom-knowledge-base). Source: - [Custom Knowledge Base Documentation](https://docs.vapi.ai/knowledge-base/custom-knowledge-base)
c
Hi Krishna, This is due to the same ongoing Google/Gemini provider issue. The Knowledge Base query relies on Gemini infrastructure, and during this incident Gemini is intermittently returning HTML error pages instead of JSON, which causes the KB lookup to fail with:
Copy code
Unexpected token '<', '<!DOCTYPE' is not valid JSON
You can track the incident and updates here: https://status.vapi.ai/incident/809181
Hi Krishna, Thank you for reporting this issue. This is a known issue that we're currently experiencing due to rate limiting with Google's Vertex AI API. You can track the status here: https://status.vapi.ai/incident/809181 What's Affected: • Knowledge Base query tool functionality • Gemini LLM models (intermittent failures) • Google-based transcription services Workarounds: If you need the Knowledge Base functionality urgently, you can: 1. Switch to a non-Google LLM provider (e.g., OpenAI GPT-4) temporarily 2. If using BYO credentials, obtain your own Google API key with separate quota We're actively working with Google to resolve this. The issue originated on Google's end, and we've implemented fallback mechanisms to mitigate impact. I apologize for the inconvenience. Please check the status page for updates. Best, Vapi Support