KC-1361: Reject share commands that target a record or folder owner#2243
Merged
Conversation
…2235) * Reject share commands that target a record or folder owner. Fail early with a clear message for share-record, share-folder, nsf-share-record, and nsf-share-folder so owners are not granted, updated, or revoked as if they were share recipients. * resolved review comments * addressed logging and variable naming comments
sk-keeper
approved these changes
Jul 23, 2026
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.
Summary
Sharing a record or folder to its owner via share-record, share-folder, nsf-share-record, or nsf-share-folder treated the owner like a normal share recipient. Grant, update, and revoke against the owner are invalid because the owner already has full access. These commands now detect that case early and fail with a clear message instead of sending a confusing or no-op share request. Ownership transfer (share-record -a owner) still works, but transferring to someone who already owns the record is rejected as a no-op.
Changes
register.py — added owner lookup helpers; share-record and share-folder now reject grant/revoke (and grant on folders) when the target is the owner; bulk user updates also skip the folder owner
helpers.py — added shared NSF owner checks and raise_if_record_share_target_is_owner
sharing_commands.py / folder_commands.py — wired the same owner rejection into nsf-share-record and nsf-share-folder
record_api.py — added find_record_owner_username for NSF record owner resolution
test_command_register.py / test_nested_share_folder.py — added tests covering grant-to-owner rejection and self ownership-transfer rejection