run-llama/llama_index · error · ValueError

No valid source provided to resolve binary data!

Error message

No valid source provided to resolve binary data!

What it means

The terminal fallback of llama-index-core's binary resolution utility: it is reached only when neither a file `path` nor a `url` argument was supplied. The function walks through path-based, base64-based, and URL-based branches, and if all preconditions failed it raises this ValueError instead of returning empty or guessed data. It almost always indicates a caller bug or a variable that silently evaluated to None.

Source

Thrown at llama-index-core/llama_index/core/utils.py:710

            else:
                # Data is not base64 encoded in the URL (URL-encoded text)
                if as_base64:
                    # Encode the text data as base64
                    return BytesIO(base64.b64encode(url_data.encode("utf-8")))
                else:
                    # Return as text bytes
                    return BytesIO(url_data.encode("utf-8"))

        headers = {
            "User-Agent": "LlamaIndex/0.0 (https://llamaindex.ai; info@llamaindex.ai) llama-index-core/0.0"
        }
        response = requests.get(url, headers=headers, timeout=(60, 60))
        response.raise_for_status()
        if as_base64:
            return BytesIO(base64.b64encode(response.content))
        return BytesIO(response.content)

    raise ValueError("No valid source provided to resolve binary data!")

View on GitHub (pinned to afd0fef371)

Solutions

  1. Pass exactly one valid source: either `path="/path/to/file"` or `url="https://..."` / `"data:..."`.
  2. Check for misspelled or unexpected keyword names against the function signature.
  3. Add an explicit caller-side check that at least one of path/url is non-None before invoking the resolver.
  4. If the value should never be None, fail earlier in your pipeline with a clearer error about which field is missing.

Example fix

# before
buf = resolve_binary_data(path=None, url=None)  # ValueError

# after
assert path or url, "provide either path or url"
buf = resolve_binary_data(url=url) if url else resolve_binary_data(path=path)
Defensive patterns

Strategy: validation

Validate before calling

def validate_binary_source(path, url):
    if not (path or url):
        raise ValueError("resolve_binary_data requires exactly one of path or url")
    return True

Prevention

When it happens

Trigger: Calling the resolver with both `path=None` and `url=None`; passing only a `data:` URL that failed an earlier branch's scheme check; passing keyword arguments with misspelled names (e.g. `image_url=` instead of `url=`) so the real parameters stay None.

Common situations: Optional config where the user left both source fields blank; conditionally-built arguments where an if/else chain forgets one branch; refactors that renamed the parameter; agent/LLM tool calls that omit required source fields.

Related errors


AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15). Data as JSON: /api/errors/4af12b7533a0b651. Report an issue: GitHub.