Fix(chat): resolve missing None-guard in _call_start_workflow crashing on both fields absent#448
Open
Jean-Regis-M wants to merge 1 commit intoGenAI-Security-Project:mainfrom
Open
Fix(chat): resolve missing None-guard in _call_start_workflow crashing on both fields absent#448Jean-Regis-M wants to merge 1 commit intoGenAI-Security-Project:mainfrom
Jean-Regis-M wants to merge 1 commit intoGenAI-Security-Project:mainfrom
Conversation
…ndor_id Root cause: No input validation existed before description[:100] was evaluated, causing TypeError when description=None. vendor_id=None was masked by the earlier crash. Solution: Add is-None check for both required fields at method entry, returning structured error JSON before any further logic executes. Impact: Two-line addition. No side effects. Deterministic for all None input combinations. Existing valid-input behavior unchanged. Signed-off-by: JEAN REGIS <240509606@firat.edu.tr>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #417
Closes CHAT-BOUNDARY-013
Summary
When
_call_start_workflowis called with bothdescription=Noneandvendor_id=None, the method raises an unhandledTypeErrorbefore any validation logic can run. This is the most degenerate possible LLM tool call all required fields absent, and it produces a hard crash instead of a recoverable error response. This PR introduces a single two-line early-return guard that resolves this case and also covers the two adjacentNone-combination cases identified in CHAT-BOUNDARY-011 and CHAT-BOUNDARY-012.Problem
ChatAssistantBase._call_start_workflowperforms no input validation before accessingdescription[:100]inside theevent_bus.emit_agent_eventcall. WhendescriptionisNone, Python raises:The
vendor_id=Nonegap is never surfaced; it is fully masked by the earlier crash. Neither field is validated before the exception is raised, leaving the agent in an unhandled error state rather than returning a structured JSON error response that the LLM can reason about.Reproduction:
Test command:
Root Cause
No
Noneguard existed at method entry. The method signature acceptsdescription: strandvendor_id: intwithout runtime enforcement, anddescription[:100]is evaluated unconditionally before any defensive check.Solution
Two lines added at the top of
_call_start_workflow, immediately after the existingbackground_tasksavailability check pattern:The guard uses strict
is Nonechecks; falsy-but-valid values such as empty strings or0are unaffected. The early return produces a structured JSON error that the LLM can interpret and recover from, consistent with all other error responses in this method.Input Coverage After Fix
descriptionvendor_idNoneNone{"error": "description and vendor_id are required"}None42{"error": "description and vendor_id are required"}"do thing"None{"error": "description and vendor_id are required"}""42"do thing"42Impact
None; all valid call paths are unaffectedis Nonecheck has no ambiguity or side effectsNoneto this method with a passing assertionTesting
Automated:
Manual assertion:
Files Changed
finbot/agents/chat.pyNoneguard at entry of_call_start_workflowTasks
description[:100]in_call_start_workflow(line 229)vendor_id=Nonegap was masked by the earlier crash both fields unvalidatedis Noneearly-return guard covering allNoneinput combinationsdescription[:100]and all other field accessis Nonestrictly, not falsy)test_chat_boundary_013_both_required_fields_none_crashesassertion to expect error JSON