{"record":{"id":"a0dbf47476760b2a","repo":"ZhuLinsen/daily_stock_analysis","slug":"internal-error-a0dbf4","errorCode":"internal_error","errorMessage":"Failed to load system configuration","messagePattern":"Failed to load system configuration","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"api/v1/endpoints/system_config.py","lineNumber":155,"sourceCode":"    },\n    summary=\"Get system configuration\",\n    description=(\n        \"Read current configuration and return display values. Server-masked \"\n        \"sensitive fields may return the mask token; clients should use \"\n        \"raw_value_exists and is_masked to interpret values.\"\n    ),\n)\ndef get_system_config(\n    include_schema: bool = Query(True, description=\"Whether to include schema metadata\"),\n    service: SystemConfigService = Depends(get_system_config_service),\n) -> SystemConfigResponse:\n    \"\"\"Load and return current system configuration.\"\"\"\n    try:\n        payload = service.get_config(include_schema=include_schema)\n        return SystemConfigResponse.model_validate(payload)\n    except Exception as exc:\n        logger.error(\"Failed to load system configuration: %s\", exc, exc_info=True)\n        raise HTTPException(\n            status_code=500,\n            detail={\n                \"error\": \"internal_error\",\n                \"message\": \"Failed to load system configuration\",\n            },\n        )\n\n\n@router.get(\n    \"/config/setup/status\",\n    response_model=SetupStatusResponse,\n    responses={\n        200: {\"description\": \"Setup status loaded\"},\n        401: {\"description\": \"Unauthorized\", \"model\": ErrorResponse},\n        500: {\"description\": \"Internal server error\", \"model\": ErrorResponse},\n    },\n    summary=\"Get first-run setup status\",\n    description=\"Read a side-effect-free setup readiness summary from saved and runtime configuration.\",","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/ZhuLinsen/daily_stock_analysis/blob/5159bd72e8373d215492dff122acc9d389e219c9/api/v1/endpoints/system_config.py#L137-L173","documentation":"Raised by GET /system/config when SystemConfigService.get_config() or response validation throws. The endpoint logs 'Failed to load system configuration' with traceback and returns a generic 500 'internal_error' — the client message deliberately omits exception details (unlike the stocks endpoints), so the server log is the source of truth.","triggerScenarios":"Corrupted or unreadable config storage; get_config raising on schema/serialization problems; SystemConfigResponse.model_validate failing because the payload shape drifted from the schema (e.g. after an upgrade).","commonSituations":"Upgrading the backend while keeping an old config file whose keys no longer validate; file permission problems on the config path; partially written config from a crashed update.","solutions":["Read the server traceback for 'Failed to load system configuration' to see whether get_config or model_validate raised","If the config store is corrupted, restore from a backup (see the env backup endpoints) or regenerate via first-run setup","After upgrades, check that config schema migrations ran; a payload/schema mismatch shows up in model_validate","Verify file permissions on the config storage path for the server process user"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if (res.status === 500 && body.error === 'internal_error') { /* surface 'config store unavailable', check server log */ }","preventionTips":["Back up the config store before upgrades (via the authenticated env backup endpoints)","Monitor for this 500 after deployments to catch schema migration gaps","Keep the server process's file permissions on config paths correct"],"tags":["api","config","internal-error","fastapi"],"backgroundTag":null,"analyzedSha":"5159bd72e8373d215492dff122acc9d389e219c9","analyzedAt":"2026-08-15T01:59:36.292Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}