OpenBB-finance/OpenBB · error · OpenBBError

The request has generated a url that is too long. Please red

Error message

The request has generated a url that is too long. Please reduce the number of symbols or countries and try again.

What it means

OpenBBError guard in EconDB extract: after URL-building, if the constructed GET URL exceeds 2000 characters the fetcher refuses to send it. The URL length grows with the number of symbols times expanded countries, plus token and date params; 2000 is a deliberately safe cross-OS cap, and the provider chose to error rather than chunk.

Source

Thrown at openbb_platform/providers/econdb/openbb_econdb/models/economic_indicators.py:313

            )
            error_message = (
                "No valid combination of indicator symbols and countries were supplied."
                + f"\nValid countries for '{query.symbol}' are: {symbol_message}"
                + f"\nIf the symbol - {query.symbol} - is missing a country code."
                + " Please add the two-letter country code or use the country parameter."
                + "\nIf already included, add '~' to the end of the symbol."
            )
            raise OpenBBError(error_message)
        url = base_url + f"%5B{','.join(new_symbols)}%5D&format=json&token={token}"
        if query.start_date:
            url += f"&from={query.start_date}"
        if query.end_date:
            url += f"&to={query.end_date}"
        # If too many indicators and countries are supplied the request url will be too long.
        # Instead of chunking we request the user reduce the number of indicators and countries.
        # This might be able to nudge higher, but it is a safe limit for all operating systems.
        if len(url) > 2000:
            raise OpenBBError(
                "The request has generated a url that is too long."
                + " Please reduce the number of symbols or countries and try again."
            )

        async def response_callback(response, session):
            """Response callback."""
            if response.status != 200:
                warn(f"Error: {response.status} - {response.reason}")
            response = await response.json()
            if response.get("results"):
                data.extend(response["results"])
            while response.get("next"):
                response = await session.get(response["next"])
                response = await response.json()
                if response.get("results"):
                    data.extend(response["results"])
            return data

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Reduce the request size: fewer symbols per call, fewer/explicit countries instead of 'all'/'g20'.
  2. Loop client-side: chunk symbols (e.g. 5 at a time) and/or countries, then concatenate the DataFrames.
  3. Trim date ranges if they are the marginal overflow.

Example fix

# before
res = obb.economy.indicator(provider="econdb", symbol=",".join(50_symbols), country="all")

# after
import pandas as pd
frames = []
for i in range(0, len(symbols), 5):
    frames.append(obb.economy.indicator(provider="econdb", symbol=",".join(symbols[i:i+5]), country="us").to_df())
res = pd.concat(frames)
Defensive patterns

Strategy: validation

Validate before calling

MAX_URL = 2000

def chunk_requests(symbols: list[str], countries: list[str]) -> list[tuple[list[str], list[str]]]:
    # base URL + token + dates leave ~1200 chars; each symbol-country pair ~8-20 chars
    budget = 1200
    chunks, cur_syms, cur_len = [], [], 0
    per_country = max(1, budget // (len(symbols) * 12))
    for i in range(0, len(countries), per_country):
        chunks.append((symbols, countries[i:i + per_country]))
    return chunks

Try / catch

from openbb_core.provider.utils.errors import OpenBBError
try:
    res = obb.economy.indicator(provider="econdb", symbol=syms, country=cs)
except OpenBBError as e:
    if "url that is too long" in str(e):
        res = pd.concat([obb.economy.indicator(provider="econdb", symbol=",".join(syms[i:i+5]), country=cs).to_df() for i in range(0, len(syms), 5)])
    else:
        raise

Prevention

When it happens

Trigger: Calling obb.economy.indicator(provider='econdb', symbol=<many indicators>, country='all' or a large group like 'g20') — each indicator×country combination is embedded in the URL, easily blowing past 2000 chars.

Common situations: Batch jobs requesting dozens of indicators across all countries; group aliases ('all', 'g20') silently expanding to 20+ countries per symbol; long date params adding the final overflow.

Related errors


AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14). Data as JSON: /api/errors/2e5e20abfd2fd4a0. Report an issue: GitHub.