Skip to content

fix: use date strings for mark attendance date#4949

Open
nareshkannasln wants to merge 2 commits into
frappe:developfrom
aerele:attendance-date
Open

fix: use date strings for mark attendance date#4949
nareshkannasln wants to merge 2 commits into
frappe:developfrom
aerele:attendance-date

Conversation

@nareshkannasln

@nareshkannasln nareshkannasln commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Description:
In the Mark Attendance dialog, the Start and End date fields set their defaults to native JS Date objects via moment().toDate(). Frappe's Date control expects a string.

Error Log: {
"exception": "frappe.exceptions.ValidationError: Wed Jul 01 2026 00:00:00 GMT+0530 (India Standard Time) is not a valid date string.",
"exc_type": "ValidationError",
"_exc_source": "hrms (app)",
"exc": "["Traceback (most recent call last):\n File \"apps/frappe/frappe/utils/data.py\", line 139, in getdate\n return datetime.date.fromisoformat(string_date)\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^\nValueError: Invalid isoformat string: 'Wed Jul 01 2026 00:00:00 GMT+0530 (India Standard Time)'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File \"apps/frappe/frappe/utils/data.py\", line 142, in getdate\n return parser.parse(string_date, dayfirst=parse_day_first).date()\n ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"env/lib/python3.14/site-packages/dateutil/parser/_parser.py\", line 1368, in parse\n return DEFAULTPARSER.parse(timestr, **kwargs)\n ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^\n File \"env/lib/python3.14/site-packages/dateutil/parser/parser.py\", line 643, in parse\n raise ParserError(\"Unknown string format: %s\", timestr)\ndateutil.parser.parser.ParserError: Unknown string format: Wed Jul 01 2026 00:00:00 GMT+0530 (India Standard Time)\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File \"apps/frappe/frappe/app.py\", line 125, in application\n response = frappe.api.handle(request)\n File \"apps/frappe/frappe/api/init.py\", line 64, in handle\n data = endpoint(**arguments)\n File \"apps/frappe/frappe/api/v1.py\", line 46, in handle_rpc_call\n return frappe.handler.handle()\n ~~~~~~~~~~~~~~~~~~~~~^^\n File \"apps/frappe/frappe/handler.py\", line 54, in handle\n data = execute_cmd(cmd)\n File \"apps/frappe/frappe/handler.py\", line 87, in execute_cmd\n return frappe.call(method, **frappe.form_dict)\n ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"apps/frappe/frappe/init.py\", line 1139, in call\n return fn(*args, **newargs)\n File \"apps/frappe/frappe/utils/typing_validations.py\", line 49, in wrapper\n return func(*args, **kwargs)\n File \"apps/hrms/hrms/hr/doctype/attendance/attendance.py\", line 440, in get_unmarked_days\n from_date = max(getdate(from_date), joining_date or getdate(from_date))\n ~~~~~~~^^^^^^^^^^^\n File \"apps/frappe/frappe/utils/data.py\", line 144, in getdate\n frappe.throw(\n ~~~~~~~~~~~~^\n \tfrappe.(\"{} is not a valid date string.\").format(frappe.bold(string_date)),\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n \ttitle=frappe.(\"Invalid Date\"),\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n )\n ^\n File \"apps/frappe/frappe/utils/messages.py\", line 159, in throw\n msgprint(\n ~~~~~~~~^\n \tmsg,\n ^^^^\n ...<7 lines>...\n \tallow_dangerous_html=allow_dangerous_html,\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n )\n ^\n File \"apps/frappe/frappe/utils/messages.py\", line 118, in msgprint\n _raise_exception()\n ~~~~~~~~~~~~~~~~^^\n File \"apps/frappe/frappe/utils/messages.py\", line 59, in _raise_exception\n raise exc\nfrappe.exceptions.ValidationError: Wed Jul 01 2026 00:00:00 GMT+0530 (India Standard Time) is not a valid date string.\n"]",
"_server_messages": "["{\"message\":\"Wed Jul 01 2026 00:00:00 GMT+0530 (India Standard Time) is not a valid date string.\",\"as_table\":false,\"title\":\"Invalid Date\",\"indicator\":\"red\",\"raise_exception\":1,\"__frappe_exc_id\":\"82565168f842d132551438938311a247cfb479d614e72c211d50d3b9\"}"]"
}

Before:

Screencast.from.2026-07-16.19-10-02.webm

After:

Screencast.from.2026-07-16.18-45-23.webm

Backport needed for v15, v16

@nareshkannasln
nareshkannasln marked this pull request as ready for review July 16, 2026 13:54
@mergify

mergify Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@greptile-apps

greptile-apps Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Safe to merge — two-line targeted fix that correctly converts moment objects to ISO date strings for Frappe's Date control.

The change is minimal and directly addresses the documented error. frappe.datetime.obj_to_str is the standard Frappe utility for this conversion, and the fix applies symmetrically to both date fields.

No files require special attention.

Reviews (1): Last reviewed commit: "chore: update date string with obj_to_st..." | Re-trigger Greptile

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.

1 participant