infiniflow/ragflow · error · ValueError

100

100

Error message

Invalid Content-Type: expect '{content_type}', got '{ctype}'

What it means

Error "Invalid Content-Type: expect '{content_type}', got '{ctype}'" thrown in infiniflow/ragflow.

Source

Thrown at api/apps/restful_apis/agent_api.py:2128

    except Exception as e:
        resp = get_data_error_result(code=RetCode.BAD_REQUEST, message=str(e))
        resp.status_code = RetCode.BAD_REQUEST
        return resp

    # 7. Parse request body
    async def parse_webhook_request(content_type):
        """Parse request based on content-type and return structured data."""

        # 1. Query
        query_data = {k: v for k, v in request.args.items()}

        # 2. Headers
        header_data = {k: v for k, v in request.headers.items()}

        # 3. Body
        ctype = request.headers.get("Content-Type", "").split(";")[0].strip()
        if ctype and ctype != content_type:
            raise ValueError(f"Invalid Content-Type: expect '{content_type}', got '{ctype}'")

        body_data: dict = {}

        try:
            if ctype == "application/json":
                body_data = await request.get_json() or {}

            elif ctype == "multipart/form-data":
                nonlocal canvas
                form = await request.form
                files = await request.files

                body_data = {}

                for key, value in form.items():
                    body_data[key] = value

                if len(files) > 10:

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Send the request with the Content-Type required by the webhook configuration.
  2. Adjust the webhook content_type setting if the caller cannot change.

Example fix

headers = {'Content-Type': 'application/json'}

When it happens

Trigger: Thrown at api/apps/restful_apis/agent_api.py:2128 when the library encounters an invalid state.

Common situations: The webhook caller posts with a Content-Type different from the configured expectation (e.g. form data instead of JSON); aligning the header prevents this error.


AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15). Data as JSON: /api/errors/dbe740c21f0d1589. Report an issue: GitHub.