Skip to content

fix: 🐛 🔧 Widen DB field uids for federated sharing#5441

Draft
moodyjmz wants to merge 1 commit intomainfrom
fix/federation-id-length
Draft

fix: 🐛 🔧 Widen DB field uids for federated sharing#5441
moodyjmz wants to merge 1 commit intomainfrom
fix/federation-id-length

Conversation

@moodyjmz
Copy link
Contributor

@moodyjmz moodyjmz commented Feb 26, 2026

Uids in several fields are not long enough for names, this shifts length 64 >>>255

  • Resolves: #
  • Target version: main

Summary

When a federated cloud ID exceeds 64 characters, the owner_uid and editor_uid columns in the oc_richdocuments_wopi table silently truncate the value. This can prevent federated users from opening documents in Collabora.

This PR adds a database migration to widen owner_uid and editor_uid from varchar(64) to varchar(255), aligning them with the maximum length of a federated cloud ID (user@remote).

Background

The oc_richdocuments_wopi table stores active Collabora editing sessions. The owner_uid column identifies the file owner and editor_uid identifies the current editor. In a federation context, these values may contain a full cloud ID in the format user@remote.domain, which can easily exceed 64 characters with longer usernames or domain names.

The columns were originally defined as varchar(64) in Version2060Date20200302131958, which matches the local Nextcloud user ID limit but does not account for federated cloud IDs.

Changes

New migration: Version10100Date20260226000000

  • Widens owner_uid from varchar(64) to varchar(255) on oc_richdocuments_wopi
  • Widens editor_uid from varchar(64) to varchar(255) on oc_richdocuments_wopi
  • Includes guard checks to only alter columns if they are below the target length
  • Returns null (no-op) if the table or columns do not exist or are already the correct size

Affected table

Table Column Before After
oc_richdocuments_wopi owner_uid varchar(64) varchar(255)
oc_richdocuments_wopi editor_uid varchar(64) varchar(255)

Notes

  • The uid columns in oc_richdocuments_direct and oc_richdocuments_assets are also varchar(64) but currently only store local user IDs ($this->userId), so they are not affected by this issue. They can be addressed separately if needed.
  • The original migration (Version2060Date20200302131958) could also be updated to use varchar(255) for these columns so that fresh installations get the correct size immediately.

TODO

  • ...

Checklist

  • Code is properly formatted
  • Sign-off message is added to all commits
  • Documentation (manuals or wiki) has been updated or is not required

@moodyjmz moodyjmz self-assigned this Feb 26, 2026
@moodyjmz moodyjmz marked this pull request as draft February 26, 2026 09:04
…d IDs

When a federated cloud ID exceeds 64 characters, the owner_uid and
editor_uid columns in oc_richdocuments_wopi silently truncate the value,
which can prevent federated users from opening documents in Collabora.

Widen both columns from varchar(64) to varchar(255) to accommodate the
full length of federated cloud IDs in the format user@remote.domain.

Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
@moodyjmz moodyjmz force-pushed the fix/federation-id-length branch from e5b9912 to 910cbc5 Compare February 26, 2026 09:08
@moodyjmz
Copy link
Contributor Author

@juliusknorr I am not sure if we should make this change into the original migration file too. Also I am not sure about backporting.

@moodyjmz
Copy link
Contributor Author

One more question though, is 255 long enough?

@juliusknorr
Copy link
Member

juliusknorr commented Feb 26, 2026

@juliusknorr
Copy link
Member

I am not sure if we should make this change into the original migration file too. Also I am not sure about backporting.

Yes, we can backport this as the tables have only temporary entires so even on larger scale systems the backported migration would not cause longer downtimes on schema changes). For the backporting process i can guide you through it.

Chaning the size in the original migration as well will be faster on initial installations as then only the first one would need to run and the others can be skipped. Less db operations to get the schema setup initially.

@moodyjmz
Copy link
Contributor Author

moodyjmz commented Feb 26, 2026

from what I see, the length of the UID can be 64

server/lib/public/IUser.php:24

public const MAX_USERID_LENGTH = 64;

and the max for a domain is 253

So, could be 318... I think - just to be clear = adding the @ sign to get to 318

@moodyjmz
Copy link
Contributor Author

@juliusknorr So I should update the original migration file here as well?

lib/Migration/Version2060Date20200302131958.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants