Skip to content

[Bug]: POSTGRES_CONNECTION_STRING with sslmode parameter breaks DatabaseSessionService (asyncpg incompatibility) #8

@jorgenosantos

Description

@jorgenosantos

Description

When POSTGRES_CONNECTION_STRING contains ?sslmode=disable, the processor service
fails to initialize the DatabaseSessionService because the asyncpg driver does not
accept the sslmode keyword argument. This causes agent test chat to return 503 or
"Authentication service error".

Affected Service

evo-ai-processor-community

Steps to Reproduce

  1. Deploy evo-ai-processor-community with:
    POSTGRES_CONNECTION_STRING=postgresql://user:pass@host:5432/db?sslmode=disable
  2. Start the processor service
  3. Navigate to Agents → Test your agent
  4. Send any message

Expected Behavior

Processor connects to database, sessions are created and agent responds normally.

Actual Behavior

Service crashes on startup with:

TypeError: connect() got an unexpected keyword argument 'sslmode'
sqlalchemy.exc.InvalidRequestError: The asyncio extension requires an async
driver to be used. The loaded 'psycopg2' is not async.
ValueError: Failed to create database engine for URL
'postgresql+psycopg2://user:pass@host:5432/db'
(psycopg2.errors.UndefinedTable) relation "sessions" does not exist

Agent test returns 503 Service Unavailable or "Authentication service error".

Workaround

Remove sslmode from the connection string:

# ❌ Breaks
POSTGRES_CONNECTION_STRING=postgresql://user:pass@host:5432/db?sslmode=disable

# ✅ Works
POSTGRES_CONNECTION_STRING=postgresql://user:pass@host:5432/db

Root Cause

The DatabaseSessionService from google.adk uses asyncpg internally. The sslmode
parameter is not a valid keyword argument for asyncpg's connect() method. Additionally,
using postgresql+psycopg2:// prefix also fails because asyncpg requires an async driver.

Suggested Fix

  1. Document in .env.example that sslmode must not be included in
    POSTGRES_CONNECTION_STRING
  2. Or strip unsupported parameters automatically before passing to the engine
  3. Or add a startup validation with a clear error message

Environment

  • OS: Ubuntu 22.04
  • Docker: Swarm (self-hosted)
  • Service Image: evoapicloud/evo-ai-processor-community:latest
  • Related: evo-crm-community#50

TypeError: connect() got an unexpected keyword argument 'sslmode'

sqlalchemy.exc.InvalidRequestError: The asyncio extension requires an async driver to be used. The loaded 'psycopg2' is not async.

ValueError: Failed to create database engine for URL 'postgresql+psycopg2://postgres:***@evo-crm-postgres:5432/evo_community'

(psycopg2.errors.UndefinedTable) relation "sessions" does not exist

sqlalchemy.exc.MissingGreenlet: greenlet_spawn has not been called; can't call await_only() here. Was IO attempted in an unexpected place?

Error searching for session b4a917bc-0fb6-43ed-9916-af0397d62dff: connect() got an unexpected keyword argument 'sslmode'

src.services.adk.runners.standard_runner - ERROR - Internal error processing request: 500: Error searching for session: connect() got an unexpected keyword argument 'sslmode'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions