Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions apps/api/plane/api/views/intake.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# Django imports
from django.core.serializers.json import DjangoJSONEncoder
from django.utils import timezone
from django.utils.html import escape
from django.db.models import Q, Value, UUIDField
from django.db.models.functions import Coalesce
from django.contrib.postgres.aggregates import ArrayAgg
Expand Down Expand Up @@ -185,12 +186,18 @@ def post(self, request, slug, project_id):

# create an issue
issue_data = request.data.get("issue", {})
# Accept both "description" and "description_json" keys for the description_json field
description_json = issue_data.get("description") or issue_data.get("description_json") or {}
description = issue_data.get("description")
description_json = issue_data.get("description_json") or {}
if "description_json" not in issue_data and isinstance(description, (dict, list)):
description_json = description
Comment on lines +190 to +192
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Preserve explicit description_json values without falsy coercion.

On Line 190, issue_data.get("description_json") or {} overwrites explicit falsy payloads (for example, []) with {}. This can silently alter client input.

Proposed fix
-        description_json = issue_data.get("description_json") or {}
-        if "description_json" not in issue_data and isinstance(description, (dict, list)):
+        description_json = issue_data.get("description_json") if "description_json" in issue_data else {}
+        if "description_json" not in issue_data and isinstance(description, (dict, list)):
             description_json = description
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
description_json = issue_data.get("description_json") or {}
if "description_json" not in issue_data and isinstance(description, (dict, list)):
description_json = description
description_json = issue_data.get("description_json") if "description_json" in issue_data else {}
if "description_json" not in issue_data and isinstance(description, (dict, list)):
description_json = description
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/api/plane/api/views/intake.py` around lines 190 - 192, The code
currently uses description_json = issue_data.get("description_json") or {} which
will replace explicit falsy values (e.g., [] or "") with {}, losing client
input; change this to explicitly check for the presence of the key: if
"description_json" in issue_data: description_json =
issue_data["description_json"] else: description_json = {} so explicit falsy
values are preserved, and keep the subsequent conditional that assigns
description_json = description only when "description_json" is not in issue_data
and description is a dict or list; refer to the description_json variable, the
issue_data dict access, and the description variable to locate the logic to
update.

description_html = issue_data.get("description_html") or "<p></p>"
if "description_html" not in issue_data and isinstance(description, str) and description:
description_html = f"<p>{escape(description)}</p>"

issue = Issue.objects.create(
name=issue_data.get("name"),
description_json=description_json,
description_html=issue_data.get("description_html", "<p></p>"),
description_html=description_html,
priority=issue_data.get("priority", "none"),
project_id=project_id,
state_id=triage_state.id,
Expand Down