Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
fix(desktop): DuplicateEntryError in add_workspace_to_desktop () and unresponsive success toast | GoodFirstPicks

fix(desktop): DuplicateEntryError in add_workspace_to_desktop () and unresponsive success toast

frappe/frappe 0 comments 5d ago
View on GitHub
lowopenScope: clearSkill match: yesFrappe / ERPNextPython

Why this is a good first issue

The issue involves fixing a duplicate entry error and a UI notification bug.

AI Summary

The issue involves two bugs: a `DuplicateEntryError` when adding workspace shortcuts due to missing existence checks, and a broken success toast due to mismatched API response handling. The fixes require adding guards for document creation and correcting the toast trigger logic.

Issue Description

Information about bug

Bug Description

There is a visual and system bug when adding a Workspace Shortcut to the desktop using the "Add to Desktop" functionality in Frappe V16. It raises a DuplicateEntryError and the success notification is broken.

1. The DuplicateEntryError Crash

When calling frappe.desk.doctype.desktop_icon.desktop_icon.add_workspace_to_desktop(workspace), the function unconditionally executes frappe.new_doc() on both Workspace Sidebar and Desktop Icon models without guarding for pre-existing documents.

Since Desktop Icon relies on autoname: "field:label" (which must be unique), attempting to insert a secondary workspace shortcut that shares a common label (such as those already present during core installations) violently crashes.

**Code impacting this: (desktop_icon.py)**
```python
@frappe.whitelist()
def add_workspace_to_desktop(workspace: str):
    sidebar = frappe.new_doc("Workspace Sidebar")  # Blind creation
    ...
    sidebar.save()

    new_icon = frappe.new_doc("Desktop Icon")  # Blind creation
    ...
    new_icon.insert()  # Crash here on duplicates
    return {"icon": new_icon.as_dict()}

####2. The Broken Success Toast Trigger In workspace.js, the standard .call() back checks r.message.status to render the success toast indicating "Workspace added to desktop". However, the API returns {"icon": {...}} instead of .status. Because of this mismatch, the notice is never fired, displaying nothing to the user even if they are fortunate enough to avoid the duplicate error. Suggested Fixes Fix frappe/erpnext#1: Add document guards to desktop_icon.py Guard insertions with existence checks to reuse existing items:

@frappe.whitelist()
def add_workspace_to_desktop(workspace: str):
    if frappe.db.exists("Workspace Sidebar", workspace):
        sidebar = frappe.get_doc("Workspace Sidebar", workspace)
    else:
        sidebar = frappe.new_doc("Workspace Sidebar")
        sidebar.title = workspace

GitHub Labels

bug

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 10 points when you complete it!

Risk Flags

  • potential side effects in UI
Loading labels...

Details

Points10 pts
Difficultylow
Scopeclear
Skill Matchyes
Test Focusedno