Skip to content

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

Merged
icewind1991 merged 2 commits into
nextcloud:masterfrom
jo23sh:fix/objectstore-mkdir-root-warning
Sep 24, 2026
Merged

icewind1991 merged 2 commits into
nextcloud:masterfrom
jo23sh:fix/objectstore-mkdir-root-warning

Conversation

@jo23sh

@jo23sh jo23sh commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

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 $force — IStorage::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
@solracsf solracsf added this to the Nextcloud 36 milestone Sep 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

@icewind1991 icewind1991 added the 3. to review Waiting for reviews label Sep 24, 2026
@icewind1991
icewind1991 merged commit 1cc43e3 into nextcloud:master Sep 24, 2026
213 of 218 checks passed
@welcome

welcome Bot commented Sep 24, 2026

Copy link
Copy Markdown

Thanks for your first pull request and welcome to the community! Feel free to keep them coming! If you are looking for issues to tackle then have a look at this selection: https://github.com/nextcloud/server/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22

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

Labels

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

4 participants