nextcloud / nextcloud/server

[Bug]: PostgreSQL duplicate key value violates unique constraint "mimetype_id_index"

Open
#54,151 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage 31-feedback bug feature: database feature: files feature: install and update
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

⚠️ This issue respects the following points: ⚠️
Bug description

Hello,
on a fresh installation on Debian 12 with PostgreSQL I got: the following error in the postgresql.log:

025-07-29 22:16:33.439 UTC [26753] DBUSER@nextcloud ERROR:  duplicate key value violates unique constraint "mimetype_id_index"
2025-07-29 22:16:33.439 UTC [26753] DBUSER@nextcloud DETAIL:  Key (mimetype)=(image/svg+xml) already exists.
2025-07-29 22:16:33.439 UTC [26753] DBUSER@nextcloud STATEMENT:  INSERT INTO "oc_mimetypes" ("mimetype") VALUES($1)
2025-07-29 22:16:33.440 UTC [26757] DBUSER@nextcloud ERROR:  duplicate key value violates unique constraint "mimetype_id_index"
2025-07-29 22:16:33.440 UTC [26757] DBUSER@nextcloud DETAIL:  Key (mimetype)=(image/svg+xml) already exists.
2025-07-29 22:16:33.440 UTC [26757] DBUSER@nextcloud STATEMENT:  INSERT INTO "oc_mimetypes" ("mimetype") VALUES($1)
Steps to reproduce
  1. Install Debian 12 in a LXC container
  2. install all dependencies and nextcloud
  3. configure postgresql
  4. install + configure nextcloud
Expected behavior

No error messages in a fresh installation

Nextcloud Server version

31

Operating system

Debian 12

PHP engine version

8.2

Web server

Apache 2.4.62

Database engine version

PostgreSQL 15.13

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

yes

Are you using the Nextcloud Server Encryption module?

no

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

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

No repository file, test, or entry point is named. Reproduce the fresh Debian 12 installation with PostgreSQL 15.13, then trace the oc_mimetypes insertion that produces the duplicate image/svg+xml error. Done means a fresh Nextcloud 31 installation completes without duplicate-key errors and the relevant regression coverage passes.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.