iflytek/astron-agent · error · ValueError
Unsupported DB_TYPE: ' '. Supported types: postgresql, mysql
Error message
Unsupported DB_TYPE: '{db_type}'. Supported types: postgresql, mysql What it means
The adapter registry maps DB_TYPE values to dialect adapters. Only postgresql and mysql have adapters; any other value raises ValueError listing the supported types. This fails fast before any DDL/DML translation is attempted.
Solutions
- Set DB_TYPE exactly to 'postgresql' or 'mysql' (check env var, config file, or request payload)
- Normalize/validate the value at config load time before reaching the registry
- If a new DB is genuinely needed, implement an Adapter class and register it in registry.py
Example fix
// before DB_TYPE=postgres // after DB_TYPE=postgresql
Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED = {'postgresql', 'mysql'}
if db_type not in SUPPORTED:
raise ValueError(f'DB_TYPE must be one of {SUPPORTED}, got {db_type!r}') Try / catch
try:
adapter = get_adapter(db_type)
except ValueError as e:
logger.error('bad DB_TYPE: %s', e)
adapter = get_adapter('postgresql') # or fail fast per policy Prevention
- Use exact canonical values 'postgresql'/'mysql' in env/config
- Normalize and validate DB_TYPE once at config load
- Add aliases (pg->postgresql) at ingestion if needed
When it happens
Trigger: get_adapter() called with db_type from env/config set to something like 'postgres', 'pg', 'oracle', 'sqlite', or an unset/uppercase variant not matching the exact expected strings.
Common situations: Environment variable DB_TYPE typo'd or using a common alias ('postgres' instead of 'postgresql'); new database type deployed without adding an adapter.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- DATA_NOT_EXIST
- Missing required environment variables for Alembic
- APP_NOT_FOUND_ERROR
- database config is nil or dbType is empty
- mysql username is empty
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/63be2cf6f78b47dd.
Report an issue: GitHub.
Appendix: source
Thrown at core/memory/database/repository/middleware/adapters/registry.py:40
if _adapter_instance is not None:
return _adapter_instance
db_type = os.getenv("DB_TYPE", "postgresql").lower()
if db_type == "postgresql":
from memory.database.repository.middleware.adapters.postgresql_adapter import (
PostgreSQLAdapter,
)
_adapter_instance = PostgreSQLAdapter()
elif db_type == "mysql":
from memory.database.repository.middleware.adapters.mysql_adapter import (
MySQLAdapter,
)
_adapter_instance = MySQLAdapter()
else:
raise ValueError(
f"Unsupported DB_TYPE: '{db_type}'. Supported types: postgresql, mysql"
)
return _adapter_instance
def reset_adapter() -> None:
"""Reset the cached adapter instance. Useful for testing."""
global _adapter_instance # noqa: PLW0603
_adapter_instance = None
View on GitHub (pinned to 5e758547a8)