Skip to content

bugfix: Evaluate actor lazily on pre-save hooks - #815

Open
john-wd wants to merge 2 commits into
jazzband:masterfrom
john-wd:bugfix/lazy-object-for-actor
Open

bugfix: Evaluate actor lazily on pre-save hooks#815
john-wd wants to merge 2 commits into
jazzband:masterfrom
john-wd:bugfix/lazy-object-for-actor

Conversation

@john-wd

@john-wd john-wd commented Apr 9, 2026

Copy link
Copy Markdown

Closes: #115

The issue reported is just an evaluation time problem; some auth libraries (like JWT auth and perhaps even on rest_framework) evaluates authentication lazily at view dispatch time, so auditlog sets the AnonymousUser in the auditlog pre-save closures, which is not right.

Use Django's own SimpleLazyObject which acts like a variable and evaluates at access time, so the proper user is used.

@john-wd john-wd changed the title use SimpleLazyObject bugfix: Evaluate actor lazily on pre-save hooks Apr 9, 2026
@codecov

codecov Bot commented Apr 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.34%. Comparing base (7e33d82) to head (e57f655).
⚠️ Report is 12 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #815   +/-   ##
=======================================
  Coverage   96.33%   96.34%           
=======================================
  Files          35       35           
  Lines        1256     1257    +1     
=======================================
+ Hits         1210     1211    +1     
  Misses         46       46           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hramezani
hramezani requested a review from 2ykwang April 9, 2026 14:48
@2ykwang 2ykwang added this to the 3.5.0 milestone Apr 9, 2026
@jontesek

Copy link
Copy Markdown

Nice, thanks. So let's merge it, or? ;d

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.

Automatic Logging doesn't log the Actor

3 participants