Budibase/budibase · error
Expected indexed request IDs to contain only strings
Error message
Expected indexed request IDs to contain only strings
What it means
parseIndexedRequestIds accepts a JSON array but every element must be a string request ID. If any element is a non-string (number, object, null, etc.), it throws Error("Expected indexed request IDs to contain only strings") because the return value must be a Set<string>.
Source
Thrown at packages/server/src/sdk/workspace/ai/agentLogs/shared.ts:283
}
export function getSessionDocId(agentId: string, sessionId: string): string {
const encodedAgentId = encodeKeyPart(agentId)
const encodedSessionId = encodeKeyPart(sessionId)
return `${DocumentType.AGENT_LOG_SESSION}${SEPARATOR}${encodedAgentId}${SEPARATOR}${encodedSessionId}`
}
export function parseIndexedRequestIds(value?: string): Set<string> {
if (!value) {
return new Set()
}
const parsed = JSON.parse(value)
if (!Array.isArray(parsed)) {
throw new Error("Expected indexed request IDs to be an array")
}
if (parsed.some(item => typeof item !== "string")) {
throw new Error("Expected indexed request IDs to contain only strings")
}
return new Set(parsed)
}
export function getWorkspaceDbForEnvironment(environment: AgentLogEnvironment) {
if (environment === "development") {
return context.getDevWorkspaceDB()
}
if (environment === "production") {
return context.getProdWorkspaceDB()
}
throw new HTTPError("Invalid environment query", 400)
}
export function getLiteLLMRequestUser(
data: LiteLLMRequestDetail | AgentLogSessionIndexDocView on GitHub (pinned to a81a902e9a)
Solutions
- Rewrite the stored array so every element is a string (String(id) on numeric IDs)
- Fix the writer to serialize IDs with JSON.stringify([...ids]) where ids is a string[]
- Catch the error and reindex the session's request IDs from the raw logs
Example fix
// before const ids = parseIndexedRequestIds(value) // throws if [123] // after const parsed: unknown[] = JSON.parse(value) const ids = parseIndexedRequestIds(JSON.stringify(parsed.map(String)))
Defensive patterns
Strategy: type-guard
Validate before calling
function isStringArray(value: unknown): value is string[] {
return Array.isArray(value) && value.every(item => typeof item === "string")
}
const parsed: unknown = JSON.parse(value)
if (!isStringArray(parsed)) {
// coerce or reindex before calling parseIndexedRequestIds
parsed = Array.isArray(parsed) ? parsed.map(String) : []
} Type guard
function isStringArray(value: unknown): value is string[] {
return Array.isArray(value) && value.every(item => typeof item === "string")
} Try / catch
try {
const ids = parseIndexedRequestIds(value)
} catch (err) {
if (err instanceof Error && /only strings/.test(err.message)) {
// reindex the session or coerce: new Set(JSON.parse(value).map(String))
}
} Prevention
- Store IDs as strings at write time (LiteLLM IDs can be numeric-looking)
- Run a one-time migration coercing array elements to strings
- Validate with isStringArray before persisting index docs
When it happens
Trigger: The stored JSON array of indexed request IDs contains at least one non-string element, e.g. [12345], [null], or [{"id":"x"}].
Common situations: IDs were serialized as numbers by a previous writer; a migration or external script wrote raw LiteLLM numeric IDs; corrupted index documents from a failed write.
Related errors
- Expected indexed request IDs to be an array
- Unknown plugin type - check schema.json: ${schema.type}
- Error fetching agent log detail: ${text || response.statusTe
- Agent log detail not found
- Cannot execute multiple queries for agent log search
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/298e335ef5cf0253.
Report an issue: GitHub.