TauricResearch/TradingAgents · error · ValueError

ticker cannot consist solely of dots: {value!r}

Error message

ticker cannot consist solely of dots: {value!r}

What it means

Raised by ticker validation in tradingagents/dataflows/utils.py when a ticker symbol passed to the data layer consists only of dot characters ('.', '..', '...'). The filesystem-path regex allows dots, but a dots-only component would traverse the parent directory when the ticker is used to build cache/report file paths, so it is rejected explicitly. This is a guard against path traversal disguised as a symbol.

Source

Thrown at tradingagents/dataflows/utils.py:41

    ``"../../../etc/foo"`` flows into ``os.path.join`` / ``Path /`` and
    escapes the configured cache, checkpoint, or results directory.

    Returns ``value`` unchanged when it matches the allowed pattern; raises
    ``ValueError`` otherwise.
    """
    if not isinstance(value, str) or not value:
        raise ValueError(f"ticker must be a non-empty string, got {value!r}")
    if len(value) > max_len:
        raise ValueError(f"ticker exceeds {max_len} chars: {value!r}")
    if not _TICKER_PATH_RE.fullmatch(value):
        raise ValueError(
            f"ticker contains characters not allowed in a filesystem path: {value!r}"
        )
    # The regex above allows '.', so values like '.', '..', '...' would pass,
    # and as a path component they traverse the parent directory. Reject any
    # value that's only dots.
    if set(value) == {"."}:
        raise ValueError(f"ticker cannot consist solely of dots: {value!r}")
    return value


def save_output(data: pd.DataFrame, tag: str, save_path: SavePathType = None) -> None:
    if save_path:
        data.to_csv(save_path, encoding="utf-8")
        print(f"{tag} saved to {save_path}")


def get_current_date():
    return date.today().strftime("%Y-%m-%d")


def decorate_all_methods(decorator):
    def class_decorator(cls):
        for attr_name, attr_value in cls.__dict__.items():
            if callable(attr_value):
                setattr(cls, attr_name, decorator(attr_value))

View on GitHub (pinned to a33fd4c0f1)

Solutions

  1. Validate/normalize the ticker before calling the data API — strip whitespace and reject dots-only values.
  2. Check the symbol against a whitelist pattern (letters, digits, '-', '.', '^') and require at least one non-dot character.
  3. If the value came from user input, surface a clear form/CLI error instead of passing it downstream.

Example fix

// before
get_YFinData(start_date, end_date, ticker='..')

// after
from tradingagents.dataflows.utils import normalize_symbol
ticker = normalize_symbol('NVDA')  # validate first, avoid '.' / '..' inputs
get_YFinData(start_date, end_date, ticker)
Defensive patterns

Strategy: validation

Validate before calling

import re

def is_valid_ticker(value: str) -> bool:
    return (
        isinstance(value, str)
        and value
        and set(value) != {'.'}
        and re.fullmatch(r'[A-Za-z0-9.^\-]+', value) is not None
    )

assert is_valid_ticker('NVDA') and not is_valid_ticker('..')

Type guard

def is_safe_ticker(value: unknown) -> value is string:
  return typeof value === 'string' && value.length > 0 && /[A-Za-z0-9.^-]/.test(value) && ![...value].every(c => c === '.')

Try / catch

try:
    data = get_YFin_data_window(start, end, ticker)
except ValueError as e:
    if 'ticker' in str(e):
        return handle_invalid_ticker(ticker)  # report to caller, do not retry
    raise

Prevention

When it happens

Trigger: Calling any dataflow function (e.g. get_YFinData / normalize-dependent helpers) with a ticker whose characters are all '.', such as ticker='.' or ticker='..'. The earlier regex check passes because '.' is an allowed path character, and this final check catches the traversal case.

Common situations: User-typed input parsed straight into a ticker field; CLI or LLM-produced arguments containing '.' or '..'; test fixtures with placeholder symbols; strings accidentally truncated to dots.

Related errors


AI-assisted analysis of TauricResearch/TradingAgents@a33fd4c0f1 (2026-08-14). Data as JSON: /api/errors/7a594e6bfdc03686. Report an issue: GitHub.