Skip to content

[BUG]: add_response_to_json() crashes when appending to non-list field #334

@SHANKAR8983

Description

@SHANKAR8983

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 method add_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

  1. Initialize JSON like:
    {
    "name": "John"
    }
  2. 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

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