{"record":{"id":"3e8ac4f013fcf795","repo":"iflytek/astron-agent","slug":"openapi-schema-server-not-exist-err","errorCode":"OPENAPI_SCHEMA_SERVER_NOT_EXIST_ERR","errorMessage":"找不到请求服务","messagePattern":"找不到请求服务","errorType":"error_code","errorClass":"SparkLinkOpenapiSchemaException","httpStatus":null,"severity":"error","filePath":"core/plugin/link/utils/open_api_schema/schema_parser.py","lineNumber":192,"sourceCode":"            # return body_schema_res\n            return body_schema\n\n    def _extract_basic_info(self, openapi: Dict[str, Any]) -> Dict[str, Any]:\n        \"\"\"Extract basic OpenAPI information.\"\"\"\n        bundles = {}\n        openapi_info = openapi[\"info\"]\n        openapi_version = openapi[\"openapi\"]\n        bundles.update({\"openapi_version\": openapi_version})\n        title = openapi_info.get(\"title\", \"\")\n        bundles.update({\"tool_title\": title})\n        description = openapi_info.get(\"description\", \"\")\n        bundles.update({\"tool_description\": description})\n        return bundles\n\n    def _validate_and_get_server_url(self, openapi: Dict[str, Any]) -> str:\n        \"\"\"Validate server configuration and return server URL.\"\"\"\n        if len(openapi[\"servers\"]) == 0:\n            raise SparkLinkOpenapiSchemaException(\n                code=ErrCode.OPENAPI_SCHEMA_SERVER_NOT_EXIST_ERR.code,\n                err_pre=ErrCode.OPENAPI_SCHEMA_SERVER_NOT_EXIST_ERR.msg,\n                err=\"找不到请求服务\",\n            )\n        return openapi[\"servers\"][0][\"url\"]\n\n    def _extract_interfaces(self, openapi: Dict[str, Any]) -> List[Dict[str, Any]]:\n        \"\"\"Extract all interfaces from OpenAPI paths.\"\"\"\n        interfaces = []\n        methods = [\"get\", \"post\", \"put\", \"delete\", \"patch\", \"head\", \"options\", \"trace\"]\n\n        for path, path_item in openapi[\"paths\"].items():\n            for method in methods:\n                if method in path_item:\n                    interfaces.append(\n                        {\n                            \"path\": path,\n                            \"method\": method,","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/plugin/link/utils/open_api_schema/schema_parser.py#L174-L210","documentation":"When parsing an OpenAPI document, _validate_and_get_server_url validates the 'servers' list before extracting the base URL. If 'servers' is empty (no request servers declared), SparkLinkOpenapiSchemaException with code OPENAPI_SCHEMA_SERVER_NOT_EXIST_ERR is raised.","triggerScenarios":"Importing a plugin/tool whose OpenAPI spec has a 'servers' key present but an empty array, e.g. servers: []. The parser then cannot determine the base URL for requests.","commonSituations":"Hand-authored OpenAPI specs missing the servers section; specs generated by tools that leave servers empty; users pasting a spec exported without a configured environment/base URL.","solutions":["Add a servers entry to the OpenAPI spec: servers: [{url: 'https://api.example.com/v1'}]","Re-export the spec from the source tool with the environment/base URL configured","If the spec is user-supplied, validate it before import and reject specs with empty servers with a clearer message"],"exampleFix":"// before (yaml)\nservers: []\n// after (yaml)\nservers:\n  - url: https://api.example.com/v1","handlingStrategy":"validation","validationCode":"def has_server(openapi: dict) -> bool:\n    servers = openapi.get(\"servers\") or []\n    return len(servers) > 0 and bool(servers[0].get(\"url\"))","typeGuard":null,"tryCatchPattern":"try:\n    parser.parse(spec)\nexcept SparkLinkOpenapiSchemaException as e:\n    if e.code == ErrCode.OPENAPI_SCHEMA_SERVER_NOT_EXIST_ERR.code:\n        # prompt user to add a servers entry\n        ...\n    raise","preventionTips":["Validate OpenAPI specs (servers present, non-empty) before import","Configure the base URL when exporting specs from source tools","Give importers clear UI feedback when servers is missing/empty"],"tags":["openapi","schema","config"],"backgroundTag":"schema-validation-failed","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}