iflytek/astron-agent · error · FileNotFoundError
Config file not found
Error message
Config file not found: {self.env_file_path} What it means
load_env_file loads key/value pairs from an env-style config file (via python-dotenv's dotenv_values) whose path was given to the constructor. Before reading, it checks os.path.exists and raises FileNotFoundError when the path does not point to an existing file, so the caller gets a clear, immediate failure instead of an empty config dict.
Solutions
- Verify the file exists at the exact path with `ls -l <path>` and fix the path passed to the constructor / CONFIG_FILE_KEY
- If running in Docker/K8s, mount the env file or bake it into the image at the expected path
- Use an absolute path or resolve relative paths against a known base directory
- Fail fast at startup with a friendly message telling the operator which path is missing
Example fix
// before
loader = ConfigLoader('/etc/app/.env')
config = loader.load_env_file() # FileNotFoundError
// after
env_path = os.environ.get('CONFIG_FILE_KEY', '/etc/app/.env')
if not os.path.exists(env_path):
raise FileNotFoundError(f'Please provide the config file at {env_path}')
loader = ConfigLoader(env_path)
config = loader.load_env_file() Defensive patterns
Strategy: validation
Validate before calling
import os
path = os.environ.get('CONFIG_FILE_KEY', default_path)
if not os.path.isfile(path):
raise FileNotFoundError(f'Config file missing: {path}') Type guard
def config_file_ok(path: str) -> bool:
return isinstance(path, str) and os.path.isfile(path) Try / catch
try:
config = loader.load_env_file()
except FileNotFoundError as e:
logger.error('Config file missing, check CONFIG_FILE_KEY: %s', e)
sys.exit(1) Prevention
- Mount/copy the env file in Docker/K8s at a fixed absolute path
- Resolve relative paths against the project root, not the CWD
- Fail at startup with a message naming the missing path
- Add a smoke check in CI that the packaged config file exists
When it happens
Trigger: Instantiating the config util with an env_file_path that does not exist on disk (typo, wrong relative path, file not mounted) and then calling load_env_file().
Common situations: Container deployments where the config file was not volume-mounted; CONFIG_FILE_KEY pointing to a stale or renamed file; running from a different working directory so relative paths resolve incorrectly; typo in the path string.
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
- -1
- RUN_LINK_URL is not set
- Missing required environment variables for Alembic
- SERVICE_PORT_KEY is not set
- LOG_PATH_KEY is not set
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/d4da22f5f587ca3d.
Report an issue: GitHub.
Appendix: source
Thrown at core/plugin/aitools/utils/config_utils.py:95
content = data.get("data", {}).get("content", "")
config_dict = dotenv_values(stream=StringIO(content))
return config_dict, content
except Exception as e:
log.exception(f"Error downloading config from Polaris: {e}")
raise
class EnvFileLoader:
def __init__(self, env_file_path: str) -> None:
self.env_file_path = env_file_path
def load_env_file(self) -> dict[str, Any]:
"""Load environment variables from a file specified by CONFIG_FILE_KEY."""
if not os.path.exists(self.env_file_path):
raise FileNotFoundError(f"Config file not found: {self.env_file_path}")
config_dict = dotenv_values(self.env_file_path)
return dict(config_dict)
class ConfigWatcher:
def __init__(self) -> None:
self.enable_polaris: bool = False
self.enable_hot_reload: bool = False
self.env_loader: Optional[EnvFileLoader] = None
self.polaris_client: Optional[PolarisClient] = None
self.config_filter: Optional[ConfigFilter] = None
self.base_url: str = ""
self.username: str = ""
self.password: str = ""View on GitHub (pinned to 5e758547a8)