Skip to content

Bug_194_EVALUATE: CHAT-BOUNDARY-011 — vendor_id=None silently forwarded to orchestrator with no validation error #415

@steadhac

Description

@steadhac

Component: finbot/agents/chat.py → VendorChatAssistant._call_start_workflow

Root cause:

# chat.py lines 198-201
task_data: dict[str, Any] = {
    "description": description,
    "vendor_id": vendor_id,   # no None check
    "parent_workflow_id": self._workflow_id,
}

vendor_id is a required parameter (no default value in the function signature) but has
no runtime guard. Python type hints are not enforced at call time. When the LLM omits
the field or sends null, vendor_id=None is accepted and written directly into
task_data, which is then dispatched to the orchestrator.

Steps to reproduce:

  1. Create a VendorChatAssistant with a mock background_tasks.
  2. Call _call_start_workflow("do something", vendor_id=None).
  3. Inspect task_data passed to background_tasks.add_task.

Expected: ValueError or {"error": ...} JSON — validation rejects None for a required field
Actual: status='started', task_data["vendor_id"] is None — dispatched to orchestrator

How to execute:

pytest tests/unit/agents/test_chat_assistant.py::TestBoundaryAndTypeValues::test_chat_boundary_011_vendor_id_none_flows_into_task_data -v

Proposed fix:

if vendor_id is None:
    return json.dumps({"error": "vendor_id is required"})

Impact: The orchestrator receives None as the vendor primary key. Any downstream
DB query using vendor_id=None will either raise a DataError (PostgreSQL) or silently
return no rows (SQLite), with no signal propagated back to the chat session. The
workflow appears to start successfully from the caller's perspective while the
orchestrator operates on a phantom vendor.

Acceptance criteria:

  • test_chat_boundary_011_vendor_id_none_flows_into_task_data updated to assert an error response (once fix is applied)
  • _call_start_workflow returns {"error": "vendor_id is required"} when vendor_id is None
  • All other _call_start_workflow tests continue to pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions