Skip to content

fix(objectstore): do not warn when ensuring the storage root exists - #63889

Open
jo23sh wants to merge 1 commit into
nextcloud:masterfrom
jo23sh:fix/objectstore-mkdir-root-warning
Open

fix(objectstore): do not warn when ensuring the storage root exists#63889
jo23sh wants to merge 1 commit into
nextcloud:masterfrom
jo23sh:fix/objectstore-mkdir-root-warning

Conversation

@jo23sh

@jo23sh jo23sh commented Sep 1, 2026

Copy link
Copy Markdown

Fixes #63888

Summary

On instances with primary object storage, every account creation logs a warning whose path renders empty:

Tried to create an object store folder that already exists: 

ObjectStoreStorage creates the storage root on the fly in getMetaData(), with $force = true, whenever the cache has no entry for it:

https://github.com/nextcloud/server/blob/master/lib/private/Files/ObjectStore/ObjectStoreStorage.php#L237-L239

SetupManager then explicitly ensures that same root exists, once per account at first filesystem setup:

https://github.com/nextcloud/server/blob/master/lib/private/Files/SetupManager.php#L335

Since that call cannot pass $forceIStorage::mkdir() declares a single parameter, and $force/$metadata exist only on the ObjectStoreStorage implementation — it takes the warning branch and reports a folder the storage created itself moments earlier. The path is the storage root, which normalises to '', hence the empty message.

What this changes

Skips the warning when the path is the storage root, since an existing root is never an error, and quotes the path so an empty one is not invisible in the log.

The nested condition is deliberate, rather than extending the surrounding if to !$force && $path !== '' && $this->file_exists($path). That would stop the function returning early for the root, letting it fall through to

if ($path === '') {
    //create root on the fly
    $data['etag'] = $this->getETag('');
    $this->getCache()->put('', $data);
    return true;
}

which re-mints the root's etag and mtime and flips the return from false to true — i.e. exactly what $force = true does, for a caller that deliberately did not pass it. Re-writing the home root's etag on each setup would risk telling sync clients the whole tree changed. Keeping the early return leaves control flow untouched and changes only what is logged.

How to test

On an instance with primary object storage:

occ user:add --password-from-env someuser

Before: one warning-level entry per account, with an empty path.
After: none. The warning still fires for any non-root folder that already exists.

Verified reproducible on 34.0.3 with S3 primary storage — the occurrence count in nextcloud.log rose by exactly one per occ user:add.

Checklist

  • Code is properly formatted
  • Sign-off message is added to all commits
  • Tested against an instance reproducing the issue

ObjectStoreStorage creates the storage root on the fly in getMetaData(),
with $force = true, whenever the cache has no entry for it. A caller that
then explicitly ensures the root exists - SetupManager does exactly that,
once per account at first filesystem setup - is warned about a folder the
storage created itself moments earlier. The message renders with an empty
path, because the root normalises to the empty string.

Skip the warning for the root, and quote the path so an empty one is not
invisible in the log.

Signed-off-by: Josua Hunziker <josh@o23.ch>
@jo23sh
jo23sh requested a review from a team as a code owner September 1, 2026 10:35
@jo23sh
jo23sh requested review from Altahrim, CarlSchwan, icewind1991 and sorbaugh and removed request for a team September 1, 2026 10:35
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.

[Bug]: "Tried to create an object store folder that already exists" warning with empty path on every account creation

2 participants