iflytek/astron-agent · error · SparkLinkOpenapiSchemaException

OPENAPI_SCHEMA_BODY_TYPE_ERR

OPENAPI_SCHEMA_BODY_TYPE_ERR

Error message

openapi schema 当前不支持{content_type}请求体

What it means

When processing an interface's requestBody, the parser only supports content type 'application/json'. Any other content type (multipart/form-data, application/x-www-form-urlencoded, text/plain, etc.) raises SparkLinkOpenapiSchemaException with code OPENAPI_SCHEMA_BODY_TYPE_ERR.

Solutions

  1. Rewrite the API spec so the request body uses application/json
  2. If the target API genuinely needs multipart/form, implement a dedicated parser branch for that content type
  3. Remove the requestBody from the operation if the endpoint takes no JSON body and encode parameters in query/path instead

Example fix

// before (yaml)
requestBody:
  content:
    application/x-www-form-urlencoded:
      schema: {...}
// after (yaml)
requestBody:
  content:
    application/json:
      schema: {...}
Defensive patterns

Strategy: validation

Validate before calling

def has_supported_body(op: dict) -> bool:
    body = op.get("requestBody") or {}
    return "application/json" in (body.get("content") or {})

Try / catch

try:
    parser.parse(spec)
except SparkLinkOpenapiSchemaException as e:
    if e.code == ErrCode.OPENAPI_SCHEMA_BODY_TYPE_ERR.code:
        logger.warning("requestBody content-type not supported")
    raise

Prevention

When it happens

Trigger: Importing a tool whose OpenAPI operation declares requestBody with content other than application/json, e.g. content: multipart/form-data or application/x-www-form-urlencoded for file uploads or form posts.

Common situations: Specs for file-upload endpoints; legacy form-based APIs; auto-generated specs from frameworks that emit form or binary content types.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at core/plugin/link/utils/open_api_schema/schema_parser.py:273

        # Process parameters
        if "parameters" in interface["operation"]:
            if result := self.schema_params_parser(
                interface["operation"]["parameters"], span=span_context
            ):
                path_schema, query_schema, header_schema = result
            else:
                path_schema = query_schema = header_schema = None

        # Process request body
        self._process_request_body_refs(interface, openapi)
        request_body = interface.get("operation", {}).get("requestBody", {})
        for content_type, content in request_body.get("content", {}).items():
            if content_type == "application/json":
                request_body_schema = self.schema_body_json_parser(
                    content, span=span_context
                )
            else:
                raise SparkLinkOpenapiSchemaException(
                    code=ErrCode.OPENAPI_SCHEMA_BODY_TYPE_ERR.code,
                    err_pre=ErrCode.OPENAPI_SCHEMA_BODY_TYPE_ERR.msg,
                    err=f"openapi schema 当前不支持{content_type}请求体",
                )

        return {
            "path_schema": path_schema,
            "query_schema": query_schema,
            "header_schema": header_schema,
            "request_body_schema": request_body_schema,
            "security_info": security_info,
            "security_type": security_type,
        }

    def _build_operation_bundle(
        self, interface: Dict[str, Any], schemas: Dict[str, Any], server_url: str
    ) -> Tuple[str, Dict[str, Any]]:
        """Build operation bundle for a single interface."""

View on GitHub (pinned to 5e758547a8)