Repository navigation
core: exclude the edited object from unique attribute checks - #27693
Merged
BeryJu merged 1 commit intoNov 8, 2026
Merged
Conversation
Uniqueness matched every row with that value, including the object being edited, so saving a user with an unchanged unique attribute was rejected. Skip that row and still reject the value on any other object.
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
BeryJu
approved these changes
Nov 8, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #27693 +/- ##
==========================================
- Coverage 93.01% 93.00% -0.01%
==========================================
Files 1237 1237
Lines 86277 86293 +16
Branches 4894 4894
==========================================
+ Hits 80248 80258 +10
- Misses 5942 5948 +6
Partials 87 87
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Contributor
|
🍒 Cherry-pick to |
BeryJu
added a commit
that referenced
this pull request
Nov 23, 2026
…pick #27693 to version-2026.8) (#27700) * core: exclude the edited object from unique attribute checks (#27693) fix: exclude the edited object from unique attribute checks Uniqueness matched every row with that value, including the object being edited, so saving a user with an unchanged unique attribute was rejected. Skip that row and still reject the value on any other object. * oops --------- Co-authored-by: alexcastgonz <[email protected]> Co-authored-by: Jens L. <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #27679
Details
What does this PR change?
Unique object attributes no longer treat the object being saved as a conflict.
ObjectAttribute.run_validationstill rejects a value that another object already has, and now skips the row that is being edited.AttributesMixinSerializerpasses that instance through.Why is this change needed?
The uniqueness lookup was
filter(attributes__key=value).exists()with no exclusion. On update the current object already stores the same value, so the check failed even when nothing else used it. Saving a user while leaving a unique attribute unchanged returned "Value is not unique." A value held by a different object is still rejected.How was this tested?
test_user_attrib_validation_unique_same_usersaves a user with a unique attribute, then patches that user with the same value and a new display name (expects 200) and patches a second user with that value (expects 400). Before the change the same-user patch returned 400. After the change,authentik/core/tests/test_object_attributes.pypasses (13 tests). The existing collision test still fails when another user already has the value.ruff checkandblack --checkare clean on the touched files.make allwas not run.Linked issues
closes #27679
Checklist
make all)make docs)AI disclosure: the code, the test, and this description were drafted with an AI coding agent (Grok).