nextcloud / nextcloud/server

[Bug]: System tag assignment silently fails after tagged file is deleted

Open
#64,446 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

1. to develop 33-feedback bug feature: tags
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

⚠️ This issue respects the following points: ⚠️
  • This is not a troubleshooting question, general support matter, or webserver/proxy problem, but likely a bug (if unsure, ask the Community Help Forum).
  • This issue is not already reported on Github OR solved at the Community Help Forum (I've searched!).
  • I'm using a maintained major version of Nextcloud Server and tested against the latest patch level. (Supported major versions and current patch levels).
  • I agree to follow Nextcloud's Code of Conduct.
  • I've tried my best to provide clear reproduction steps that someone unfamiliar with this bug could use to reproduce it.
Bug description

When a tag has been assigned to a file or folder, and that file/folder is subsequently deleted, attempting to assign the same system tag to a different file afterwards fails silently (no visible error in the UI). The tag assignment simply does not take effect.

The only workarounds found so far are:

  1. Restore the deleted file/folder from the trash, unassign the tag from it, and then the tag can be assigned to the new file normally, or
  2. Delete the tag entirely via the admin Tags settings and recreate a new tag with the same name.

This suggests a stale row is left behind in oc_systemtag_object_mapping referencing the deleted file's fileid/tagid pair, which blocks or conflicts with new assignments of the same tag.

Steps to reproduce
  1. Create a new tag (e.g. "Test").
  2. Assign the tag to a file or folder (File A).
  3. Delete File A (send it to trash, or permanently delete it).
  4. Try to assign the same tag ("Test") to a different file (File B).
  5. The assignment fails — the tag does not get applied to File B.
Expected behavior

Deleting a tagged file should not affect the ability to assign the same tag to other, unrelated files. The tag assignment mapping for the deleted file should either be cleaned up automatically, or at minimum not interfere with tagging other files.

Nextcloud Server version

33

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.5

Web server

Apache (supported)

Database engine version

PostgreSQL

Is this bug present after an update or on a fresh install?

Fresh Nextcloud Server install

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?
  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other
Configuration report

List of activated Apps

Nextcloud Signing status

Nextcloud Logs

Additional info

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the tag-assignment sequence with File A and File B, then inspect the oc_systemtag_object_mapping table for stale fileid/tagid rows after deletion. Trace the system-tag assignment path and verify the fix by confirming that deleting a tagged file no longer prevents assigning the same tag to another file.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, postgresql
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.