BerriAI/litellm · error · Exception

Error getting policy from DB: {e}

Error message

Error getting policy from DB: {e}

What it means

Catch-all from get_policy_by_id_from_db: the find_unique query or the row-to-response conversion failed with a database/deserialization error; the original exception is embedded. A missing policy returns None instead — this error means the lookup itself broke.

Source

Thrown at litellm/proxy/policy_engine/policy_registry.py:568

        Get a policy by ID from the database.

        Args:
            policy_id: The ID of the policy to retrieve
            prisma_client: The Prisma client instance

        Returns:
            PolicyDBResponse if found, None otherwise
        """
        try:
            policy: Final = await _policy_table(prisma_client).find_unique(where={"policy_id": policy_id})

            if policy is None:
                return None

            return _row_to_policy_db_response(policy)
        except Exception as e:
            verbose_proxy_logger.exception("Error getting policy from DB: %s", e)
            raise Exception(f"Error getting policy from DB: {e}")

    def get_policy_by_id_for_request(self, policy_id: str) -> tuple[str, Policy] | None:
        """
        Return a policy version by ID from in-memory cache (no DB access).

        Used when the request body specifies policy_<uuid> to execute a specific version
        (e.g. published or draft). The cache is populated by sync_policies_from_db,
        which loads draft and published versions keyed by policy_id.

        Args:
            policy_id: The policy version ID (raw UUID, no prefix)

        Returns:
            (policy_name, Policy) if found, None otherwise
        """
        return self._policies_by_id.get(policy_id)

    async def get_all_policies_from_db(

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Check DB connectivity and logs; verify the policy ID, then retry.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at litellm/proxy/policy_engine/policy_registry.py:568 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/21ec7b082bbc408e. Report an issue: GitHub.