Skip to content

Lack ways to ensure idempotence when adding users/groups entitled to manage advanced permissions using OCC commands #4236

@brlin-tw

Description

@brlin-tw

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Steps to reproduce

  1. Create team folder
  2. Run sudo -u apache php /var/www/html/nextcloud/occ groupfolders:permissions --manage-add --user admin -- 1
  3. Run the same command again.

Expected behaviour

This command shouldn't arbitrarily fail even when the entitled user is already added.

Another expected behavior would be I can query whether the user/group is already added with another OCC command, and skip this command when it is the case. However as far as I can tell such command isn't implemented yet.

Actual behaviour

The following error occurred:

In DbalException.php line 56:
                                                                                                  
  An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation  
  : 1062 Duplicate entry '1-user-admin' for key 'PRIMARY'                                         
                                                                                                  

In ExceptionConverter.php line 64:
                                                                                                  
  An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation  
  : 1062 Duplicate entry '1-user-admin' for key 'PRIMARY'                                         
                                                                                                  

In Exception.php line 24:
                                                                                                  
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-user-admin' for key '  
  PRIMARY'                                                                                        
                                                                                                  

In Statement.php line 130:
                                                                                                  
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-user-admin' for key '  
  PRIMARY'                                                                                        
                                                                                                  

Known workaround

Force remove the entitled user/group before running the command works.

Server configuration

Operating system: Rocky Linux 9

Web server: Apache httpd 2.4.62-7.el9.x86_64

Database: MariaDB 10.5.27-1.el9_5.0.2.x86_64

PHP version: 8.2.30

Nextcloud version: 31.0.12

Team folders version: 19.1.12

Updated from an older Nextcloud/ownCloud or fresh install: false

Where did you install Nextcloud from: Server archive

Are you using external storage, if yes which one: local

Are you using encryption: no

Are you using an external user-backend, if yes which one: false

Client configuration

Browser: Firefox 146.0.1

Operating system: Ubuntu 25.10

Logs

No related logs found for this issue.

Web server error log

N/A

Nextcloud log (data/nextcloud.log)

No related logs found for this issue.

Browser log

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions