{"record":{"id":"c9f6bde578cafb4c","repo":"iflytek/astron-agent","slug":"log-path-key-is-not-set","errorCode":null,"errorMessage":"LOG_PATH_KEY is not set","messagePattern":"LOG_PATH_KEY is not set","errorType":"console","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"core/plugin/link/app/start_server.py","lineNumber":143,"sourceCode":"            port=int(service_port),\n            workers=20,\n            reload=False,\n            log_config=None,\n        )\n        uvicorn_server = uvicorn.Server(uvicorn_config)\n        uvicorn_server.run()\n\n\ndef spark_link_app() -> FastAPI:\n    \"\"\"\n    Create Spark Link app.\n\n    Returns:\n        FastAPI: The configured FastAPI application instance\n    \"\"\"\n    log_path = os.getenv(const.LOG_PATH_KEY)\n    if not log_path:\n        raise ValueError(\"LOG_PATH_KEY is not set\")\n    configure(\n        os.getenv(const.LOG_LEVEL_KEY),\n        Path(__file__).parent.parent / log_path,\n    )\n\n    init_data_base()\n\n    # Run database migration before starting the service\n    from extensions.database_migration import run_database_migration\n\n    run_database_migration()\n\n    load_create_tool_schema()\n    load_update_tool_schema()\n    load_http_run_schema()\n    load_tool_debug_schema()\n    load_mcp_register_schema()\n    spark_link_init_sid()","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/plugin/link/app/start_server.py#L125-L161","documentation":"spark_link_app reads const.LOG_PATH_KEY from the environment and raises ValueError when it is unset or empty, because the log file path is required to configure logging (via configure(...)) before the app and database are initialized.","triggerScenarios":"Creating the FastAPI app (start_uvicorn -> spark_link_app, or importing `app`) while LOG_PATH_KEY is missing from the environment — uvicorn's app factory fails during startup.","commonSituations":"Deploying without the logging env var defined in the manifest; .env not loaded before uvicorn starts; a typo/renamed log-path variable; empty string set in container config which passes os.getenv but not the truthiness check.","solutions":["Set LOG_PATH_KEY's underlying env var (e.g. LOG_PATH=logs/spark_link.log) before starting the server","Ensure the path is writable relative to the app root (log_path is joined with Path(__file__).parent.parent)","Add the variable to the deployment env_file / k8s env section","Optionally provide a default log path in code if unset logging is acceptable"],"exampleFix":"// before\n# container env has no LOG_PATH\nValueError: LOG_PATH_KEY is not set\n// after\n# docker-compose.yml\nenvironment:\n  - LOG_PATH=logs/link.log\n  - LOG_LEVEL=INFO","handlingStrategy":"validation","validationCode":"import os\nassert os.getenv('LOG_PATH'), 'LOG_PATH must be set before starting the app'","typeGuard":null,"tryCatchPattern":"try:\n    application = spark_link_app()\nexcept ValueError as e:\n    print(f'App factory failed: {e}; ensure LOG_PATH is configured')\n    raise SystemExit(1)","preventionTips":["Set LOG_PATH (and LOG_LEVEL) in the deployment env_file","Ensure the log directory exists and is writable relative to the app root","List required env vars in a startup validation script","Avoid setting env vars to empty strings in manifests — they still fail the truthiness check"],"tags":["config","env","logging","startup"],"backgroundTag":"missing-env-var","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}