litellm icon indicating copy to clipboard operation
litellm copied to clipboard

[Bug]: Prisma client falling back to WASM mode despite PRISMA_QUERY_ENGINE_TYPE=binary

Open ecda909 opened this issue 9 months ago • 0 comments

What happened?

I'm encountering an issue with my LiteLLM deployment where, despite setting PRISMA_QUERY_ENGINE_TYPE=binary and confirming its presence in the runtime environment, Prisma still attempts to use its WASM mode. During startup, Prisma generates the client and then fails with an error stating: Error: Env var PRISMA_QUERY_ENGINE_BINARY is provided but provided path binary can't be resolved. This is followed by a validation error indicating that the datasource URL isn’t recognized—even though my connection string (e.g., postgresql://llmproxy:dbpassword9090@db:5432/litellm) is correct.

I expected Prisma to use its native binary (as directed by PRISMA_QUERY_ENGINE_TYPE=binary), correctly generate the Prisma client, and connect to our PostgreSQL database without falling back to WASM mode.

Any guidance on how to resolve this conflict between the environment variables, or how to ensure that Prisma consistently uses the native binary instead of falling back to WASM mode, would be greatly appreciated!

Here's the docker-compose.yml: `version: "3.9" services: db: image: postgres:13 restart: always environment: POSTGRES_DB: litellm POSTGRES_USER: llmproxy POSTGRES_PASSWORD: dbpassword9090 healthcheck: test: ["CMD-SHELL", "pg_isready -h 127.0.0.1 -U llmproxy -d litellm"] interval: 5s timeout: 5s retries: 10

redis: image: redis:7-alpine restart: always healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 5s timeout: 5s retries: 10

litellm: build: . restart: unless-stopped ports: - "4000:4000" environment: LITELLM_MASTER_KEY: "..." LITELLM_SALT_KEY: "..." DATABASE_URL: "postgresql://llmproxy:dbpassword9090@db:5432/litellm" LITELLM_WORKER_CONFIG: "/app/config/worker_config.yaml" depends_on: db: condition: service_healthy redis: condition: service_healthy volumes: - ./config/config.yaml:/app/config/config.yaml:ro - ./config/worker_config.yaml:/app/config/worker_config.yaml:ro`

Dockerfile: `FROM cgr.dev/chainguard/python:latest-dev

USER root WORKDIR /app

ENV HOME=/home/litellm ENV PATH="${HOME}/venv/bin:$PATH"

RUN apk update && apk add openssl

RUN python -m venv ${HOME}/venv &&
${HOME}/venv/bin/pip install --upgrade pip

COPY requirements.txt . RUN ${HOME}/venv/bin/pip install --no-cache-dir -r requirements.txt

COPY . /app

COPY entrypoint.sh /app/entrypoint.sh RUN chmod +x /app/entrypoint.sh

Expose port 4000

EXPOSE 4000

ENTRYPOINT ["/app/entrypoint.sh"]

Start LiteLLM using our config file

CMD ["--port", "4000", "--config", "/app/config/config.yaml"] `

requirements.yml: litellm[proxy]==1.11.1 prisma==0.15.0 fastapi>=0.104.1 uvicorn>=0.24.0 pydantic>=2.4.2 python-dotenv>=1.0.0 typing-extensions>=4.8.0 redis>=5.0.1 sqlalchemy>=2.0.22 psycopg2-binary>=2.9.9 prometheus-client>=0.17.1 backoff>=2.2.1 opentelemetry-api>=1.18.0 opentelemetry-sdk>=1.18.0 opentelemetry-exporter-otlp>=1.18.0

entrypoint.sh: `#!/bin/sh if [[ ! "${DATABASE_URL}" == postgresql://* ]] && [[ ! "${DATABASE_URL}" == postgres://* ]]; then echo "DATABASE_URL=postgresql://${DATABASE_URL#*://}" > /app/.env else echo "DATABASE_URL=${DATABASE_URL}" > /app/.env fi

echo "LITELLM_MASTER_KEY=${LITELLM_MASTER_KEY}" >> /app/.env echo "LITELLM_SALT_KEY=${LITELLM_SALT_KEY}" >> /app/.env if [ -n "${LITELLM_WORKER_CONFIG}" ]; then echo "LITELLM_WORKER_CONFIG=${LITELLM_WORKER_CONFIG}" >> /app/.env fi

echo "Created .env file with DATABASE_URL and other environment variables"

exec litellm "$@"`

Relevant log output

Relevant log output:
DATABASE_URL is: postgresql://llmproxy:dbpassword9090@db:5432/litellm
PRISMA_QUERY_ENGINE_TYPE is: binary
PRISMA_QUERY_ENGINE_TYPE=binary
...
Generating Prisma client...
Error: Env var PRISMA_QUERY_ENGINE_BINARY is provided but provided path binary can't be resolved.
...
Error validating datasource client: the URL must start with the protocol postgresql:// or postgres://.

Are you a ML Ops Team?

Yes

What LiteLLM version are you on ?

v1.11.1

Twitter / LinkedIn details

No response

ecda909 avatar Mar 17 '25 19:03 ecda909