iflytek/astron-agent · error · Exception

Security type not found in security schema

Error message

Security type {security_type} not found in security schema

What it means

Generic Exception raised in process_authentication when the resolved operation's security_type key is absent from its security schema dict. It means the OpenAPI-derived security definition does not contain the scheme the tool was configured to use, so credentials cannot be applied.

Solutions

  1. Compare the tool's stored security_type against the keys of its security schema and re-register/update the tool so they match.
  2. Fix the OpenAPI document's securitySchemes names and re-upload the tool.
  3. Log operation_id_schema['security'] keys at this point to see what schemes are actually available.
  4. Return a structured 4xx error instead of bare Exception so callers can repair tool config programmatically.

Example fix

// before
security_type = operation_id_schema["security_type"]
if security_type not in operation_id_schema["security"]:
    raise Exception(f"Security type {security_type} not found in security schema")
// after
security_type = operation_id_schema.get("security_type")
available = list(operation_id_schema["security"])
if security_type not in available:
    raise ToolAuthConfigError(
        f"security_type={security_type!r} missing; available schemes: {available}")
Defensive patterns

Strategy: validation

Validate before calling

def auth_config_ok(schema: dict) -> bool:
    sec = schema.get("security") or {}
    return schema.get("security_type") in sec

Try / catch

try:
    process_authentication(operation_id_schema, message_header)
except Exception as e:
    log.error("auth config mismatch for operation: %s", e)
    return error_response(422, "tool security config invalid; re-publish tool")

Prevention

When it happens

Trigger: handle_request_execution -> process_authentication with operation_id_schema['security'] truthy but operation_id_schema['security_type'] not a key of that security mapping — typically a mismatch between the security_type recorded at registration and the schemes present in the OpenAPI document.

Common situations: Tool registered against an older/newer OpenAPI schema where the security scheme was renamed or removed; schema re-upload changed scheme names; bad JSON produced by the schema extraction pipeline storing security as a dict keyed differently.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/43cb4df3874288e4. Report an issue: GitHub.

Appendix: source

Thrown at core/plugin/link/service/community/tools/http/execution_server.py:214

            sid=span_context.sid,
        ),
        payload={},
    )


def process_authentication(
    operation_id_schema: Dict[str, Any],
    message_header: Dict[str, Any],
    message_query: Dict[str, Any],
    tool_id: str,
) -> None:
    """Process authentication for the request."""
    if not operation_id_schema["security"]:
        return

    security_type = operation_id_schema["security_type"]
    if security_type not in operation_id_schema["security"]:
        raise Exception(f"Security type {security_type} not found in security schema")

    api_key_info = operation_id_schema["security"].get(security_type)
    auth_name = api_key_info.get("name", None)
    auth_value = api_key_info.get("x-value", None)
    if not auth_name or not auth_value:
        raise Exception(f"auth name:{auth_name}, auth value:{auth_value}")

    if api_key_info.get("type") == "apiKey":
        api_key_dict = {auth_name: auth_value}
        if api_key_info.get("in") == "header":
            message_header.update(api_key_dict)
        elif api_key_info.get("in") == "query":
            message_query.update(api_key_dict)


def validate_response_schema(  # noqa: C901
    result_json: Any, open_api_schema: Dict[str, Any]
) -> List[str]:

View on GitHub (pinned to 5e758547a8)