fix(chart-tools): ensure configurable dict mutation and coerce data points (#23287)
DI
11h ago+211+211+012345678901234567890123456789-4-4-0123456789
Summary
Closes #23287
Resolves two critical issues in create_chart_tool (backend/utils/retrieval/tools/chart_tools.py):
- 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 leavingconfigunchanged (inline chart dropped from response). - If
configcontained{'configurable': None},config.get('configurable', {})returnedNone, raisingTypeError: 'NoneType' object does not support item assignment. - Now safely ensures
config['configurable']is a dict before settingchart_data.
- Previously,
- 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.
- Hermetic unit tests:
- Added
backend/tests/unit/test_chart_tools.pywith 5 tests covering configurable persistence,Nonehandling, input coercion, validations, and execution without context.
- Added
Payout Address
- Wallet: 0xC345C07229307d4f1c7935aD2cAe48e390215808
- Network: Polygon / Base / Arbitrum / Stellar