ZhuLinsen/daily_stock_analysis · error · HTTPException

internal_error

internal_error

Error message

Failed to load system configuration

What it means

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.

Source

Thrown at api/v1/endpoints/system_config.py:155

    },
    summary="Get system configuration",
    description=(
        "Read current configuration and return display values. Server-masked "
        "sensitive fields may return the mask token; clients should use "
        "raw_value_exists and is_masked to interpret values."
    ),
)
def get_system_config(
    include_schema: bool = Query(True, description="Whether to include schema metadata"),
    service: SystemConfigService = Depends(get_system_config_service),
) -> SystemConfigResponse:
    """Load and return current system configuration."""
    try:
        payload = service.get_config(include_schema=include_schema)
        return SystemConfigResponse.model_validate(payload)
    except Exception as exc:
        logger.error("Failed to load system configuration: %s", exc, exc_info=True)
        raise HTTPException(
            status_code=500,
            detail={
                "error": "internal_error",
                "message": "Failed to load system configuration",
            },
        )


@router.get(
    "/config/setup/status",
    response_model=SetupStatusResponse,
    responses={
        200: {"description": "Setup status loaded"},
        401: {"description": "Unauthorized", "model": ErrorResponse},
        500: {"description": "Internal server error", "model": ErrorResponse},
    },
    summary="Get first-run setup status",
    description="Read a side-effect-free setup readiness summary from saved and runtime configuration.",

View on GitHub (pinned to 5159bd72e8)

Solutions

  1. Read the server traceback for 'Failed to load system configuration' to see whether get_config or model_validate raised
  2. If the config store is corrupted, restore from a backup (see the env backup endpoints) or regenerate via first-run setup
  3. After upgrades, check that config schema migrations ran; a payload/schema mismatch shows up in model_validate
  4. Verify file permissions on the config storage path for the server process user
Defensive patterns

Strategy: try-catch

Try / catch

if (res.status === 500 && body.error === 'internal_error') { /* surface 'config store unavailable', check server log */ }

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of ZhuLinsen/daily_stock_analysis@5159bd72e8 (2026-08-15). Data as JSON: /api/errors/a0dbf47476760b2a. Report an issue: GitHub.