{"record":{"id":"43cb4df3874288e4","repo":"iflytek/astron-agent","slug":"security-type-security-type-not-found-in-security-schema","errorCode":null,"errorMessage":"Security type {security_type} not found in security schema","messagePattern":"Security type (.+?) not found in security schema","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"core/plugin/link/service/community/tools/http/execution_server.py","lineNumber":214,"sourceCode":"            sid=span_context.sid,\n        ),\n        payload={},\n    )\n\n\ndef process_authentication(\n    operation_id_schema: Dict[str, Any],\n    message_header: Dict[str, Any],\n    message_query: Dict[str, Any],\n    tool_id: str,\n) -> None:\n    \"\"\"Process authentication for the request.\"\"\"\n    if not operation_id_schema[\"security\"]:\n        return\n\n    security_type = operation_id_schema[\"security_type\"]\n    if security_type not in operation_id_schema[\"security\"]:\n        raise Exception(f\"Security type {security_type} not found in security schema\")\n\n    api_key_info = operation_id_schema[\"security\"].get(security_type)\n    auth_name = api_key_info.get(\"name\", None)\n    auth_value = api_key_info.get(\"x-value\", None)\n    if not auth_name or not auth_value:\n        raise Exception(f\"auth name:{auth_name}, auth value:{auth_value}\")\n\n    if api_key_info.get(\"type\") == \"apiKey\":\n        api_key_dict = {auth_name: auth_value}\n        if api_key_info.get(\"in\") == \"header\":\n            message_header.update(api_key_dict)\n        elif api_key_info.get(\"in\") == \"query\":\n            message_query.update(api_key_dict)\n\n\ndef validate_response_schema(  # noqa: C901\n    result_json: Any, open_api_schema: Dict[str, Any]\n) -> List[str]:","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/plugin/link/service/community/tools/http/execution_server.py#L196-L232","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Compare the tool's stored security_type against the keys of its security schema and re-register/update the tool so they match.","Fix the OpenAPI document's securitySchemes names and re-upload the tool.","Log operation_id_schema['security'] keys at this point to see what schemes are actually available.","Return a structured 4xx error instead of bare Exception so callers can repair tool config programmatically."],"exampleFix":"// before\nsecurity_type = operation_id_schema[\"security_type\"]\nif security_type not in operation_id_schema[\"security\"]:\n    raise Exception(f\"Security type {security_type} not found in security schema\")\n// after\nsecurity_type = operation_id_schema.get(\"security_type\")\navailable = list(operation_id_schema[\"security\"])\nif security_type not in available:\n    raise ToolAuthConfigError(\n        f\"security_type={security_type!r} missing; available schemes: {available}\")","handlingStrategy":"validation","validationCode":"def auth_config_ok(schema: dict) -> bool:\n    sec = schema.get(\"security\") or {}\n    return schema.get(\"security_type\") in sec","typeGuard":null,"tryCatchPattern":"try:\n    process_authentication(operation_id_schema, message_header)\nexcept Exception as e:\n    log.error(\"auth config mismatch for operation: %s\", e)\n    return error_response(422, \"tool security config invalid; re-publish tool\")","preventionTips":["Validate security_type against securitySchemes at tool registration","Re-validate tools after OpenAPI schema updates","Log available security scheme keys on mismatch"],"tags":["authentication","openapi","tool-registration"],"backgroundTag":"invalid-config-value","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"}