Primary_action not passing arguments correctly to whitelisted method inside frappe.msgprint()

Heya :wave:,

I’m having an issue with primary_action in frappe.msgprint() not properly passing arguments to a whitelisted method.

The Issue

When using primary_action to call frappe.core.doctype.user.user.reset_password, I get:

TypeError: reset_password() missing 1 required positional argument: 'user'

Code

Important context note: this code is part of a server script.

frappe.msgprint(
    msg="Email already exists. Click button to receive password reset email.",
    title="Existing User",
    indicator="orange",
    primary_action={
        'label': 'Send Reset Email',
        'server_action': 'frappe.core.doctype.user.user.reset_password',
        'args': {'user': doc.email},
    },
    raise_exception=True
)

What I’ve Verified

  • Network payload shows correct data: {"user":"test@example.com"}
  • Method signature: def reset_password(user: str) -> str:
  • Method is whitelisted: @frappe.whitelist(allow_guest=True, methods=["POST"])

Attempted Solutions

Tried different argument formats:

  • 'args': {'user': doc.email} :x:
  • 'args': doc.email :x:
  • 'user': doc.email :x:

Has anyone encountered this issue with primary_action argument passing form a frappe.msgprint() call? Is there a known workaround or correct syntax for passing arguments to whitelisted methods via primary_action?

Any insights would be greatly appreciated!
Cheers,
Antoine.