infiniflow/ragflow · error · Exception

400

400

Error message

Empty Bearer token

What it means

Error "Empty Bearer token" thrown in infiniflow/ragflow.

Source

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

        auth = request.authorization
        if not auth or auth.username != username or auth.password != password:
            raise Exception("Invalid Basic Auth credentials")

    def _validate_jwt_auth(security_cfg):
        """Validate JWT token in Authorization header."""
        jwt_cfg = security_cfg.get("jwt", {})
        secret = jwt_cfg.get("secret")
        if not secret:
            raise Exception("JWT secret not configured")

        auth_header = request.headers.get("Authorization", "")
        if not auth_header.startswith("Bearer "):
            raise Exception("Missing Bearer token")

        token = auth_header[len("Bearer ") :].strip()
        if not token:
            raise Exception("Empty Bearer token")

        alg = (jwt_cfg.get("algorithm") or "HS256").upper()

        decode_kwargs = {
            "key": secret,
            "algorithms": [alg],
        }
        options = {}
        if jwt_cfg.get("audience"):
            decode_kwargs["audience"] = jwt_cfg["audience"]
            options["verify_aud"] = True
        else:
            options["verify_aud"] = False

        if jwt_cfg.get("issuer"):
            decode_kwargs["issuer"] = jwt_cfg["issuer"]
            options["verify_iss"] = True
        else:

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Provide a non-empty token after the 'Bearer ' prefix.

Example fix

headers = {'Authorization': f'Bearer {token.strip()}'}

When it happens

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

Common situations: The Authorization header contains 'Bearer' with no token, often from an unset environment variable; ensuring the token is populated prevents this error.


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