Repository navigation
Conversation
…ercion, and configurable resilience
|
The production change here is correct and nicely scoped — every guard kills a real crash path, and the tests are genuinely hermetic (10/10 pass in a clean run of this head). Two non-blocking notes below. backend/utils/retrieval/tools/chart_tools.py
backend/tests/unit/test_chart_tools.py
Security: no new dependencies or workflow changes; the f-string error messages echo caller-supplied values but are returned as plain text, so no injection surface. Blast radius is a single chat-visualization tool — if wrong, worst case is a returned error string. USER IMPACT: Users should see fewer broken or missing charts in chat when the model sends slightly malformed chart arguments (wrong casing, string numbers, empty titles) — invalid input now returns a clean error the model can retry on instead of crashing. Nothing blocking from my side. Optional nit for a follow-up: booleans currently pass validation silently ( by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Closing as a later copy of #23094. That pull request already adds the list and configurable guards in chart_tools.py. |
|
Hey @ghazy2001 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Before your next PR, please skim:
If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing. Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! |
Failure-Class: none
Summary
Hardens
backend/utils/retrieval/tools/chart_tools.pyagainst runtime crashes during chat visualization generation and adds a comprehensive hermetic unit test suite:Defensive Input Validation & Null Guards:
labelsandvaluesagainstNoneand non-list types, preventingTypeError: object of type 'NoneType' has no len().labelsandvalues.Case-Insensitive Chart Type Normalization:
chart_type(e.g."Line","BAR"normalize to"line","bar"), avoiding false rejections from slight model casing variations.Numeric Coercion & Finite Value Validation:
["7.2", "8.0"]or[2024, 2025]) into floats while safely stringifying labels.NaN, andInfvalues cleanly to prevent downstream client-side chart crashes.Configurable Dictionary Resilience:
configurableis safely initialized even whenconfig.get('configurable')returnsNone, eliminatingTypeError: 'NoneType' object does not support item assignment.Hermetic Unit Test Suite:
backend/tests/unit/test_chart_tools.pywith 10 unit tests (10/10 passing) covering valid line/bar charts, color assignment, casing normalization, invalid chart types, null guards, length mismatches, numeric coercion, invalid/NaN/Inf values, andNoneconfigurable resilience.Bounty Proposal ($50 USD)
mahmoudghazy2001@gmail.com).