Skip to content

Misleading 'Falling back to DatabaseSessionService' log for PostgreSQL URIs #4890

@mmphego

Description

@mmphego

Description

When configuring session_service_uri with a PostgreSQL URI (e.g., postgresql+asyncpg://...), the startup logs emit a message that implies a fallback/failure:

INFO - Using session service URI: postgresql+asyncpg://host:5432/mydb
INFO - Falling back to DatabaseSessionService for URI: postgresql+asyncpg://host:5432/mydb

This is misleading because DatabaseSessionService is the correct and intended handler for PostgreSQL URIs. The word "Falling back" implies something went wrong, when in reality the registry simply doesn't have an explicit registration for the postgresql+asyncpg scheme — and the code intentionally falls through to DatabaseSessionService.

This caused confusion in our team during a production debugging session, where we initially suspected the session service wasn't initializing correctly.

Location

google/adk/cli/utils/service_factory.py — around line 197-208:

service = registry.create_session_service(session_service_uri, **kwargs)
if service is not None:
    return service

# Fallback to DatabaseSessionService if the registry doesn't support the
# session service URI scheme.
from ...sessions.database_session_service import DatabaseSessionService

logger.info(
    "Falling back to DatabaseSessionService for URI: %s",
    _redact_uri_for_log(session_service_uri),
)
return DatabaseSessionService(db_url=session_service_uri, **fallback_kwargs)

Suggested Fix

Either register DatabaseSessionService in the registry for common SQL URI schemes so the fallback path isn't hit, or change the log message to be informative rather than implying failure:

logger.info(
    "Using DatabaseSessionService for URI: %s",
    _redact_uri_for_log(session_service_uri),
)

Environment

  • google-adk==1.27.2
  • Python 3.13
  • PostgreSQL via asyncpg

Metadata

Metadata

Assignees

No one assigned

    Labels

    services[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions