{"record":{"id":"b54fc70e416fe05c","repo":"BerriAI/litellm","slug":"error-getting-table-info-exc","errorCode":null,"errorMessage":"Error getting table info: {exc}","messagePattern":"Error getting table info: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/focus/database.py","lineNumber":117,"sourceCode":"            return pl.DataFrame(db_response, infer_schema_length=None)\n        except Exception as exc:\n            raise RuntimeError(f\"Error retrieving usage data: {exc}\") from exc\n\n    async def get_table_info(self) -> dict[str, Any]:\n        \"\"\"Return metadata about the spend table for diagnostics.\"\"\"\n        client: Final = self._ensure_prisma_client()\n\n        info_query: Final = \"\"\"\n        SELECT column_name, data_type, is_nullable\n        FROM information_schema.columns\n        WHERE table_name = 'LiteLLM_DailyUserSpend'\n        ORDER BY ordinal_position;\n        \"\"\"\n        try:\n            columns_response: Final = await client.db.query_raw(info_query)\n            return {\"columns\": columns_response, \"table_name\": \"LiteLLM_DailyUserSpend\"}\n        except Exception as exc:\n            raise RuntimeError(f\"Error getting table info: {exc}\") from exc\n","sourceCodeStart":99,"sourceCodeEnd":118,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/focus/database.py#L99-L118","documentation":"get_table_info runs a small information_schema query describing the LiteLLM_DailyUserSpend columns and wraps query_raw in try/except, re-raising as RuntimeError('Error getting table info: ...') with the cause chained. It exists as a diagnostics helper for the Focus export pipeline, so its failure usually indicates the same underlying problems as the usage query: connectivity, permissions, or catalog access.","triggerScenarios":"Database unreachable when the diagnostics call runs; the DB role lacks read access to information_schema.columns; Prisma client disconnected (proxy shutting down) during the call.","commonSituations":"Health-check scripts calling get_table_info against a misconfigured replica; export tooling probing schema right after proxy startup before Prisma finished connecting; hardened DB roles with catalog permissions revoked.","solutions":["Read __cause__ for the underlying Prisma/Postgres error","Verify database connectivity and that prisma_client is connected before probing","Grant the DB role SELECT on LiteLLM_DailyUserSpend and read on information_schema","Use this endpoint deliberately as a pre-flight check before get_usage_data"],"exampleFix":"# before\ninfo = await db.get_table_info()\n\n# after\ntry:\n    info = await db.get_table_info()\nexcept RuntimeError:\n    logger.exception('Focus table probe failed; cause=%s', sys.exc_info()[1].__cause__)\n    raise","handlingStrategy":"try-catch","validationCode":"async def table_probe(db: FocusLiteLLMDatabase) -> dict[str, Any] | None:\n    try:\n        return await db.get_table_info()\n    except RuntimeError:\n        return None","typeGuard":null,"tryCatchPattern":"try:\n    info = await db.get_table_info()\nexcept RuntimeError as e:\n    logger.error('table probe failed; cause=%s', e.__cause__)\n    info = None  # diagnostics only; do not fail the export job on probe failure","preventionTips":["Treat get_table_info as a probe: its failure should degrade diagnostics, not crash exports","Ensure the DB role can read information_schema.columns before relying on it","Log the chained cause to distinguish permissions from connectivity"],"tags":["litellm","focus","database","sql","diagnostics"],"backgroundTag":"database-query-failed","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}