-
Notifications
You must be signed in to change notification settings - Fork 144
Description
name: Bug Report
about: Create a report to help us improve FireForm.
title: "[BUG]: add_response_to_json() crashes when appending to non-list field"
labels: bug
assignees: ''
Describe the Bug
The methodadd_response_to_json()assumes that existing field values are always lists. However, when a field already contains a string value, attempting to call.append()on it results in an AttributeError.
This causes the application to crash when multiple values are assigned to the same field.
👣 Steps to Reproduce
- Initialize JSON like:
{
"name": "John"
} - Call:
add_response_to_json("name", "Mike")
📉 Expected Behavior
The existing string value should be converted into a list and then appended:
["John", "Mike"]
🖥️ Actual Behavior
Raises:
AttributeError: 'str' object has no attribute 'append'
🖥️ Environment Information
OS: Any
Python Version: 3.x
Module: src/llm.py
📋 Error Logs
AttributeError: 'str' object has no attribute 'append'
🕵️ Possible Fix
Add type checking before appending:
if field in self._json: if isinstance(self._json[field], list): self._json[field].append(parsed_value) else: self._json[field] = [self._json[field], parsed_value] else: self._json[field] = parsed_value