[WEB-4088] fix: issue exports when cycles are not present#7057
[WEB-4088] fix: issue exports when cycles are not present#7057
Conversation
WalkthroughThis change introduces explicit type annotations and detailed docstrings to all major functions in the export task module. It refactors helper logic for extracting creator names, improves attachment and cycle data handling, and corrects data update logic for assignees and labels. Export provider mappings are made explicit. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ExportTask
participant FileAssetDB
participant S3
participant Exporter
User->>ExportTask: Trigger issue_export_task(provider, workspace_id, ...)
ExportTask->>FileAssetDB: Query issue attachments (entity_type=ISSUE_ATTACHMENT)
ExportTask->>Exporter: Generate export file (CSV/JSON/XLSX)
Exporter->>ExportTask: Return generated file
ExportTask->>S3: Upload export file to S3
ExportTask-->>User: Export task completion
Possibly related PRs
Suggested labels
Poem
Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🧰 Additional context used🧬 Code Graph Analysis (1)apiserver/plane/bgtasks/export_task.py (2)
🪛 Ruff (0.8.2)apiserver/plane/bgtasks/export_task.py94-94: Line too long (93 > 88) (E501) 205-205: Line too long (96 > 88) (E501) 311-311: Line too long (119 > 88) (E501) 323-323: Line too long (120 > 88) (E501) 335-335: Line too long (120 > 88) (E501) 358-358: Line too long (123 > 88) (E501) ⏰ Context from checks skipped due to timeout of 90000ms (3)
🔇 Additional comments (10)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Pull Request Linked with Plane Work Items Comment Automatically Generated by Plane |
There was a problem hiding this comment.
Actionable comments posted: 1
🔭 Outside diff range comments (2)
apiserver/plane/bgtasks/export_task.py (2)
254-282:⚠️ Potential issue
update_json_rowmerges the wrong fields and breaks on list ⇄ string mismatches
- Compares
label not in existing_assignees, clearly a copy-paste error.- Tries to concatenate
list(assignee) tostr, raisingTypeError.- Assignees / labels are lists in the source row – treat them as such.
- existing_assignees, existing_labels = ( - rows[matched_index]["Assignee"], - rows[matched_index]["Labels"], - ) - assignee, label = row["Assignee"], row["Labels"] - - if assignee is not None and ( - existing_assignees is None or label not in existing_assignees - ): - rows[matched_index]["Assignee"] += f", {assignee}" - if label is not None and ( - existing_labels is None or label not in existing_labels - ): - rows[matched_index]["Labels"] += f", {label}" + existing_assignees = set(rows[matched_index].get("Assignee", [])) + existing_labels = set(rows[matched_index].get("Labels", [])) + + new_assignees = set(row.get("Assignee", [])) + new_labels = set(row.get("Labels", [])) + + rows[matched_index]["Assignee"] = sorted(existing_assignees | new_assignees) + rows[matched_index]["Labels"] = sorted(existing_labels | new_labels)
286-308: 🛠️ Refactor suggestion
update_table_rowuses wrong column indexes (priority / created-by instead of labels / assignees)Column layout from
generate_table_row:… 8 = Created By, 9 = Labels, …, 21 = Assignees …Current slice
rows[matched_index][7:9]captures Priority & Created By, not Assignees & Labels.
Updating the wrong columns silently corrupts exported data.- existing_assignees, existing_labels = rows[matched_index][7:9] - assignee, label = row[7:9] + existing_assignees = rows[matched_index][21] + existing_labels = rows[matched_index][9] + assignee = row[21] + label = row[9] @@ - rows[matched_index][8] += f", {assignee}" + rows[matched_index][21] = ", ".join( + sorted(set(filter(None, existing_assignees.split(", ")) | set(filter(None, assignee.split(", "))))) + ) @@ - rows[matched_index][8] += f", {label}" + rows[matched_index][9] = ", ".join( + sorted(set(filter(None, existing_labels.split(", ")) | set(filter(None, label.split(", "))))) + )
🧹 Nitpick comments (2)
apiserver/plane/bgtasks/export_task.py (2)
86-89: Possible encoding issue when archiving text files
zipfile.writestr()treats astras DOS-encoded CP437 bytes, which mangles any non-ASCII character in CSV/JSON contents.
Convert strings to UTF-8 bytes before writing:- for filename, file_content in files: - zipf.writestr(filename, file_content) + for filename, file_content in files: + if isinstance(file_content, str): + file_content = file_content.encode("utf-8") + zipf.writestr(filename, file_content)
348-355: Minor: avoid creating" "when only one name part exists
get_created_bywill return"John "(trailing space) iflast_nameis empty.
Tiny nit, but trimming avoids cosmetic artifacts in exports.- return f"{obj.created_by.first_name} {obj.created_by.last_name}" + full_name = f"{obj.created_by.first_name} {obj.created_by.last_name}".strip() + return full_name
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apiserver/plane/bgtasks/export_task.py(17 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
apiserver/plane/bgtasks/export_task.py
94-94: Line too long (93 > 88)
(E501)
205-205: Line too long (96 > 88)
(E501)
311-311: Line too long (119 > 88)
(E501)
323-323: Line too long (120 > 88)
(E501)
335-335: Line too long (120 > 88)
(E501)
358-358: Line too long (123 > 88)
(E501)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Analyze (javascript)
- GitHub Check: Analyze (python)
…7057) * fix: issue exports when cycles are not present * fix: type check
* fix: issue exports when cycles are not present * fix: type check
Description
Type of Change
Test Scenarios
References
WEB-4088
Summary by CodeRabbit