Skip to content

Warn when Audited.current_user_method references undefined method#773

Open
55728 wants to merge 1 commit intocollectiveidea:mainfrom
55728:warn-on-undefined-current-user-method
Open

Warn when Audited.current_user_method references undefined method#773
55728 wants to merge 1 commit intocollectiveidea:mainfrom
55728:warn-on-undefined-current-user-method

Conversation

@55728
Copy link
Copy Markdown

@55728 55728 commented Apr 4, 2026

Problem

When `Audited.current_user_method` is set to a method that doesn't exist on the controller, audited silently falls back to `nil`, resulting in audit records with no user. This makes misconfiguration very difficult to detect, especially in compliance-critical applications (#772).

Solution

Emit a warning via `Kernel#warn` when the configured method is not defined on the controller, while preserving the existing behavior of recording a nil user. This avoids breaking existing applications while making the misconfiguration visible in logs.

A future major version could consider raising an error instead.

Ref #772

When Audited.current_user_method is configured with a method name that the controller does not respond to, audited silently returns nil, resulting in audit records with a nil user. This makes misconfiguration difficult to detect.

This change emits a warning via Kernel#warn when the configured method is not defined on the controller, while preserving the existing behavior of recording a nil user.

Ref collectiveidea#772
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