iflytek/astron-agent · critical · RuntimeError
Something went wrong creating the database and tables.
Error message
Something went wrong creating the database and tables.
What it means
After attempting to create all tables, create_db_and_tables() re-inspects the database and verifies that every required table (hardcoded ['tools_schema']) exists. If a required table is still absent, it raises RuntimeError. This is a post-condition check: table creation silently failed or was skipped without raising.
Solutions
- Verify the engine's connection URL points to the database you actually expect (log engine.url).
- Manually list tables (SHOW TABLES / \dt) in the connected DB to see what exists and under which schema.
- Check earlier logs for swallowed OperationalError warnings from table.create() — the 'already exists' path may have hidden a real failure.
- Create the missing table manually or drop/recreate the database, then rerun create_db_and_tables().
Example fix
# before
table.create(self.engine, checkfirst=True)
# after
table.create(self.engine, checkfirst=True)
logger.info("created %s in db %s", table.name, self.engine.url.database) # confirm DDL hits the intended DB Defensive patterns
Strategy: validation
Validate before calling
from sqlalchemy import inspect
names = inspect(engine).get_table_names()
assert "tools_schema" in names, f"tools_schema missing from {engine.url}; tables={names}" Try / catch
try:
service.create_db_and_tables()
except RuntimeError:
logger.error("required tables missing; check DB URL=%s", service.engine.url) Prevention
- Log engine.url at startup to confirm which database DDL runs against.
- Watch for earlier 'Table ... already exists, skipping' warnings — they can mask real failures.
- Pin a single DATABASE_URL across services so DDL and verification hit the same DB/schema.
When it happens
Trigger: DDL ran against a different database/schema than the one inspected; OperationalError 'table already exists' was swallowed but the table is in another schema; a failure path left table.create() skipped; the inspector looks at the wrong engine/database (connection points to a different DB than where DDL executed).
Common situations: Wrong DATABASE_URL pointing at an empty database while tables were created elsewhere earlier; MySQL schema/search_path mismatch; table created by another deploy under a different name; checkfirst=True skipping creation because a same-named table exists in a different schema of the same server.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/363fd427defe3d10.
Report an issue: GitHub.
Appendix: source
Thrown at core/plugin/link/domain/models/utils.py:232
for table in SQLModel.metadata.sorted_tables:
try:
table.create(self.engine, checkfirst=True)
except OperationalError as oe:
logger.warning(
f"Table {table} already exists, skipping. Exception: {oe}"
)
except Exception as exc:
logger.error(f"Error creating table {table}: {exc}")
raise RuntimeError(f"Error creating table {table}") from exc
# Now check if the required tables exist, if not, something went wrong.
inspector = inspect(self.engine)
table_names = inspector.get_table_names()
for table_name in current_tables:
if table_name not in table_names:
logger.error("Something went wrong creating the database and tables.")
logger.error("Please check your database settings.")
raise RuntimeError(
"Something went wrong creating the database and tables."
)
logger.debug("Database and tables created successfully")
class RedisService:
"""Redis service for caching operations.
Provides Redis connection management, caching operations, and both
single Redis and Redis Cluster support.
"""
name = "redis_service"
def __init__(
self,
cluster_addr: str,View on GitHub (pinned to 5e758547a8)