fix(chart-tools): ensure configurable dict mutation and coerce data points (#23287)

DI
11h ago
+211-4

Summary

Closes #23287

Resolves two critical issues in create_chart_tool (backend/utils/retrieval/tools/chart_tools.py):

  1. Configurable binding & mutation:
    • Previously, configurable = config.get('configurable', {}) retrieved a detached temporary dictionary when the 'configurable' key was missing, silently mutating the temporary dictionary while leaving config unchanged (inline chart dropped from response).
    • If config contained {'configurable': None}, config.get('configurable', {}) returned None, raising TypeError: 'NoneType' object does not support item assignment.
    • Now safely ensures config['configurable'] is a dict before setting chart_data.
  2. Defensive data point coercion:
    • Defensively coerces data point labels to strings and values to floats (fallback to 0.0 on invalid/null/bool), preventing wire schema and downstream serialization errors.
  3. Hermetic unit tests:
    • Added backend/tests/unit/test_chart_tools.py with 5 tests covering configurable persistence, None handling, input coercion, validations, and execution without context.

Payout Address

  • Wallet: 0xC345C07229307d4f1c7935aD2cAe48e390215808
  • Network: Polygon / Base / Arbitrum / Stellar