nextcloud / nextcloud/server

[Bug]: file with size different from 0 in oc_filecache but with size 0 on S3 primary storage

Open
#56,380 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage 31-feedback bug
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

We have NC 31.0.9 with a Scality platform as S3 primary storage.
I noticed in NC log a few "Failed to open stream: HTTP request failed! HTTP/1.1 416 Range Not Satisfiable" errors for some files.
After investigating, it is because Nextcloud sends a "Range: bytes=0-" header to the S3 platform (https://github.com/nextcloud/server/blob/master/lib/private/Files/ObjectStore/S3ObjectTrait.php#L46), but the size of the object on the S3 storage platform is 0. And using "Range: bytes=x-x" with AWS S3 SDK seems to always return "416 Range Not Satisfiable" when the object is empty (I tested with aws cli with the same file that Nextcloud was trying to access).
But the "size" column in oc_filecache table for this file has value "138".

awss3api get-object --bucket bucket_name --key urn:oid:5272234 output
{
"AcceptRanges": "bytes",
"LastModified": "2025-11-06T09:24:31+00:00",
"ContentLength": 0,
"ETag": ""d41d8cd98f00b204e9800998ecf8427e"",
"VersionId": "3938323337353738393238343935393939393939524730303120203432342e313134313638383832322e3137323330383330",
"ContentType": "application/octet-stream",
"ServerSideEncryption": "AES256",
"Metadata": {}
}

awss3api get-object --bucket bucket_name --key urn:oid:5272234 --range "bytes=0-" output
An error occurred (InvalidRange) when calling the GetObject operation: The requested range cannot be satisfied.

fileid | storage | path | path_hash | parent | name | mimetype | mimepart | size | mtime | storage_mtime | encrypted | unencrypted_size | etag | permissions | checksum
---------+---------+-------------------------------------------------------------------------------------------+----------------------------------+---------+------------------------+----------+----------+------+------------+---------------+-----------+------------------+---------------+-------------+----------
5272234 | 1 | __groupfolders/39/FOLDER1/FOLDER2/FOLDER3/FOLDER4/FILENAME1.kdbx.FilTFD | 84a55b007b85a1cdcf82a9bc6814c988 | 3521974 | FILENAME1.kdbx.FilTFD | 14 | 3 | 165 | 1762421071 | 1762421071 | 0 | 0 | 690c694fad0db | 27 |

  1. How can the size field in the DB have a different value than the size of the object on S3 storage?
  2. Could you try to send a fopen request to S3 storage platform without the Range header, if you sent the first request with "Range: bytes=0-" and received "416 Range Not Satisfiable" as response? And if this second fopen fails, then you throw an exception.
Steps to reproduce
Expected behavior

file size should be consistent across db and s3 storage

check the returned total size from the content-range header against the expected size

Nextcloud Server version

31

Operating system

None

PHP engine version

None

Web server

None

Database engine version

None

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

None

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 reading lib/private/Files/ObjectStore/S3ObjectTrait.php around line 46 and trace how the S3 object size and Range request are handled. The issue provides no reproduction steps or test file, so first establish a case where the database size differs from an empty S3 object. Done means the size mismatch and 416 fallback behavior are covered by the relevant tests and the requested consistency check is satisfied.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, php
Domain
backend, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.