Skip to content

[BUG]: Mutable default argument in textToJSON causes data leakage between instances #29

@pigeio

Description

@pigeio

name: 🐛 Bug Report
about: Create a report to help us improve FireForm.
title: "[BUG]: "
labels: bug
assignees: ''


⚡️ Describe the Bug

The textToJSON.init method in src/backend.py (line 11) uses a mutable default argument json={}. In Python, default arguments are evaluated once at function definition time, not at each call. This means every instance of textToJSON that doesn't explicitly pass json shares the same dictionary object. Data extracted from one incident report silently leaks into the next.

👣 Steps to Reproduce

  1. Open a python shell or create a test script
  2. Run the following

from backend import textToJSON

This requires Ollama running, but the bug can be proven with a minimal example:

class Demo:
def init(self, data={}):
self.data = data

a = Demo()
a.data["officer_name"] = "John Doe"

b = Demo()
print(b.data)
print(a.data is b.data) # True ← same object in memory

  1. In FireForm's context: process two different incident reports sequentially without restarting the container — the second report will contain fields from the first .

📉 Expected Behavior

Each textToJSON instance should have its own isolated dictionary. Processing Report 2 should never contain data from Report 1.

🖥️ Environment Information

  • OS: Windows 11 / Any (bug is language-level, not OS-specific)
  • Docker/Compose Version: Any - Ollama Model used: N/A (bug is in Python code, not LLM-dependent)

📸 Screenshots/Logs

Image

🕵️ Possible Fix

def init(self, transcript_text, target_fields, json=None):
if json is None:
json = {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions