Skip to content

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

@yemkareems

Description

@yemkareems

⚠️ 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    0. Needs triagePending check for reproducibility or if it fits our roadmap31-feedbackbug

    Type

    Projects

    Status

    Triaged

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions