Skip to content

Conversation

@xzzy
Copy link
Collaborator

@xzzy xzzy commented Nov 25, 2025

No description provided.

@xzzy xzzy merged commit 27c0c3a into dbca-wa:django_5_upgrade Nov 25, 2025
4 of 5 checks passed
Comment on lines +203 to +210
def render(self, name, value, attrs=None, *args, **kwargs):
substitutions = self.get_context(name, value, attrs)
substitutions.update({
'initial_text': self.initial_text,
'input_text': self.input_text,
'clear_template': '',
'clear_checkbox_label': self.clear_checkbox_label,
}
})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: get_template_substitution_values() returns None, causing TypeError when substitutions.update(None) is called.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

When self.is_initial(value) is true, the code attempts to call substitutions.update(self.get_template_substitution_values(value)). However, get_template_substitution_values() is commented out and returns None. This leads to a TypeError: 'NoneType' object is not iterable, causing a server crash when rendering forms with existing files.

💡 Suggested Fix

Uncomment and implement get_template_substitution_values() to return a dictionary with initial and initial_url keys, ensuring substitutions.update() receives a valid iterable.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: ledger/widgets.py#L203-L210

Potential issue: When `self.is_initial(value)` is true, the code attempts to call
`substitutions.update(self.get_template_substitution_values(value))`. However,
`get_template_substitution_values()` is commented out and returns `None`. This leads to
a `TypeError: 'NoneType' object is not iterable`, causing a server crash when rendering
forms with existing files.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 3430431

Comment on lines +203 to 213
def render(self, name, value, attrs=None, *args, **kwargs):
substitutions = self.get_context(name, value, attrs)
substitutions.update({
'initial_text': self.initial_text,
'input_text': self.input_text,
'clear_template': '',
'clear_checkbox_label': self.clear_checkbox_label,
}
})

#if 'multiple' in attrs:
#final_attrs = self.build_attrs(attrs, type=self.input_type, name=name,)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: FILE_INPUT_CONTRADICTION is used without import, causing NameError when contradictory file input occurs.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

The constant FILE_INPUT_CONTRADICTION is referenced in value_from_datadict() methods (e.g., line 373) without being imported. When a user attempts to upload a new file and simultaneously checks the 'clear' checkbox, this code path is executed, resulting in a NameError: name 'FILE_INPUT_CONTRADICTION' is not defined, which crashes the application.

💡 Suggested Fix

Import FILE_INPUT_CONTRADICTION from django.forms.fields or django.forms.widgets to resolve the NameError.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: ledger/widgets.py#L200-L213

Potential issue: The constant `FILE_INPUT_CONTRADICTION` is referenced in
`value_from_datadict()` methods (e.g., line 373) without being imported. When a user
attempts to upload a new file and simultaneously checks the 'clear' checkbox, this code
path is executed, resulting in a `NameError: name 'FILE_INPUT_CONTRADICTION' is not
defined`, which crashes the application.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 3430431

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants