iflytek/astron-agent · error · FileNotFoundError
alembic.ini not found
Error message
alembic.ini not found: {alembic_ini} What it means
_build_alembic_config constructs the Alembic Config from <link_dir>/alembic.ini. If the file does not exist on disk it logs the missing path and raises FileNotFoundError. The migration runner depends on Alembic's ini for script_location and DB URL plumbing, so it refuses to continue without it.
Solutions
- Verify the file exists at the expected link_dir (the logged path in the error) and restore alembic.ini if deleted
- Fix packaging so alembic.ini and the alembic/ directory ship with the module (package_data, MANIFEST.in, or Dockerfile COPY)
- Correct the link_dir argument/path resolution so it points at the module directory containing alembic.ini
- Pull the latest link module sources if the checkout is stale or partial
Example fix
// before (Dockerfile) COPY core/plugin/link/*.py ./link/ // after (Dockerfile) COPY core/plugin/link/ ./link/ # includes alembic.ini and alembic/
Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path
def ensure_alembic_files(link_dir: Path) -> bool:
return (link_dir / "alembic.ini").exists() and (link_dir / "alembic").is_dir() Try / catch
try:
run_database_migration(link_dir)
except FileNotFoundError as e:
if "alembic.ini" in str(e):
sys.exit(f"Deployment error: {e}")
raise Prevention
- Ensure Dockerfiles COPY the whole link module directory, not just *.py
- Declare alembic.ini/alembic in package_data or MANIFEST.in if packaged as a wheel
- Don't gitignore alembic.ini; commit migration configs with the code
- Smoke-test the packaged artifact (not just the source tree) in CI
When it happens
Trigger: Calling run_database_migration when the link module directory does not contain alembic.ini — e.g. the package was installed/packaged without the alembic directory, or link_dir points at the wrong path in the deployed image.
Common situations: Docker image or wheel built that excludes non-Python files (missing package_data / MANIFEST entries); running from a working directory where the relative link path resolves elsewhere; alembic.ini accidentally gitignored or deleted; partial checkout.
Understand the failure class
Background: "Config file not found": what it means and how to fix it in docker-sync, Maven, Vagrant, Turborepo and other tools — this error's family across 60 libraries.
Related errors
- can not find
- can not find
- Config file not found
- credential file is unavailable
- Missing required environment variables for Alembic
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/9e8e24ad29d2a5a5.
Report an issue: GitHub.
Appendix: source
Thrown at core/plugin/link/extensions/database_migration.py:71
(const.MYSQL_PASSWORD_KEY, mysql_password),
(const.MYSQL_DB_KEY, mysql_db),
]
if not value
]
if missing_envs:
raise ValueError(
"Missing required MySQL environment variables for migration: "
f"{', '.join(missing_envs)}"
)
def _build_alembic_config(link_dir: Path) -> Config:
"""Build Alembic config from local link module files."""
alembic_dir = link_dir / "alembic"
alembic_ini = link_dir / "alembic.ini"
if not alembic_ini.exists():
logging.error("alembic.ini not found: %s", alembic_ini)
raise FileNotFoundError(f"alembic.ini not found: {alembic_ini}")
config = Config(str(alembic_ini))
config.set_main_option("script_location", str(alembic_dir))
return config
def _get_or_create_redis_service() -> RedisService:
"""Get or create Redis service instance."""
redis_service = get_redis_engine()
if redis_service is not None:
logging.info("redis_service is successfully got from get_redis_engine()")
return redis_service
redis_addr = os.getenv(const.REDIS_CLUSTER_ADDR_KEY) or os.getenv(
const.REDIS_ADDR_KEY
)
redis_password = os.getenv(const.REDIS_PASSWORD_KEY)
if not redis_addr:View on GitHub (pinned to 5e758547a8)