#5329·hrms

bug: 'Duplicate Name: HR Telemetry Milestone ... already exists' dialog on every save after the first (sites < 30 days old)

Author: mark-weassist-ioCreated Sep 30, 2026Updated Sep 30, 2026

Information about bug

On a site younger than 30 days, every new Job Opening after the first one shows a red "Duplicate Name: HR Telemetry Milestone recruitment_started already exists" dialog on save. The document saves fine; the dialog is noise that confuses users. The same happens for every doctype in CREATION_MILESTONES / SUBMISSION_MILESTONES (Employee, Shift Type, Leave Type, Salary Structure, Appraisal Cycle, Employee Onboarding, Salary Slip) and every other capture_first call. It happens even with System Settings > Enable Telemetry switched off.

Cause

hrms/telemetry.py _claim_milestone inserts the milestone and relies on savepoint(catch=Exception) to swallow the duplicate:

https://github.com/frappe/hrms/blob/develop/hrms/telemetry.py

The exception is caught, but BaseDocument.db_insert has already called frappe.msgprint(..., title=_("Duplicate Name")) before raising DuplicateEntryError (it only skips that when ignore_if_duplicate=True), so the message reaches the client. Also, capture_first never checks whether telemetry is enabled, so the milestone row is written on sites that opted out.

Steps to reproduce

  1. Fresh site (Administrator created < 30 days ago), telemetry off.
  2. Create and save a Job Opening. No dialog.
  3. Create and save a second Job Opening. Red "Duplicate Name" dialog.

Suggested fix

diff
 def _claim_milestone(event: str) -> bool:
+	if frappe.db.exists(MILESTONE_DOCTYPE, event):
+		return False
 	claimed = False
 	with savepoint(catch=Exception):
-		frappe.get_doc({"doctype": MILESTONE_DOCTYPE, "event": event}).insert(ignore_permissions=True)
+		frappe.get_doc({"doctype": MILESTONE_DOCTYPE, "event": event}).insert(
+			ignore_permissions=True, ignore_if_duplicate=True
+		)
 		claimed = True
 	return claimed

and return early from capture / capture_first when telemetry is off (frappe.utils.telemetry.pulse.client.is_enabled() is false).

Module

HR

Version

Frappe v16.34.2, HRMS v16.19.0 (same code on develop and version-16-hotfix as of 2026-09-30)

Installation method

Docker (frappe_docker)