Repository navigation
Description
⚠️ This issue respects the following points: ⚠️
- This is a bug, not a question or a configuration/webserver/proxy issue.
- This issue is not already reported on Github OR Nextcloud Community Forum (I've searched it).
- Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
- I agree to follow Nextcloud's Code of Conduct.
Bug description
TypeError in Sabre CorePlugin when handling public DAV HEAD range (master, stable32 and previous) breaks fast PDF loading
relates my PR nextcloud/3rdparty#2241
Affected versions
- stable32 (32.0.3.2) and earlier stable branches (stable31/stable30/...)
- master (current)
Environment
- Nextcloud: 32.0.3.2 (stable32)
- PHP: PHP 8.3.28
- Webserver: (apache/nginx)
- Client: PDF viewer / curl
Steps to reproduce
Steps to reproduce
- Create a public share link for a single PDF file (not folder).
- Access the public DAV endpoint (e.g. viewer or
HEADrequest on/public.php/dav/files/<token>). - Observe slow load and server log TypeError.
Expected behavior
Expected behavior
Public DAV HEAD/range requests should not throw; range support should work for efficient PDF streaming.
Nextcloud Server version
master
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?
Encryption is Disabled
What user-backends are you using?
- Default user-backend (database)
- LDAP/ Active Directory
- SSO - SAML
- Other
Configuration report
List of activated Apps
fails with master, stable32 and previous
see additional info...Nextcloud Signing status
Technical information
=====================
The following list covers which files have failed the integrity check. Please read
the previous linked documentation to learn more about the errors and how to fix
them.
Results
=======
- files_mindmap
- EXCEPTION
- OC\IntegrityCheck\Exceptions\InvalidSignatureException
- Certificate is not valid.
Raw output
==========
Array
(
[files_mindmap] => Array
(
[EXCEPTION] => Array
(
[class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
[message] => Certificate is not valid.
)
)
)Nextcloud Logs
Additional info
Actual behavior
stream_get_meta_data() is called with a string body ("") during HEAD, causing a TypeError and breaking range loading.
Log excerpt (stable32)
"app":"webdav","method":"HEAD","url":"/public.php/dav/files/<token>",
"message":"stream_get_meta_data(): Argument #1 ($stream) must be of type resource, string given",
"File":"/var/www/html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","Line":179
Log excerpt (master)
"app":"webdav","method":"HEAD","url":"/public.php/dav/files/<token>",
"message":"stream_get_meta_data(): Argument #1 ($stream) must be of type resource, string given",
"File":"/var/www/html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","Line":179
Analysis
CorePlugin::httpGet() sets $body = '' for HEAD but does not convert it to a stream. Later, range handling calls stream_get_meta_data($body) which fails on string bodies. This breaks range support used by PDF viewers, causing very slow loads.
Proposed fix
Convert string body to stream regardless of request method:
line 86++
if (is_string($body)) {
$stream = fopen('php://temp', 'r+');
fwrite($stream, $body);
rewind($stream);
$body = $stream;
}This preserves range handling while avoiding the TypeError. Guarding stream_get_meta_data() with is_resource() in line 179 would avoid the crash but may skip proper range handling.
Behavior before/after patch
Before patch (stable32 / master)
curl -I -H "Range: bytes=0-1023" http://localhost:8080/public.php/dav/files/<token>
HTTP/1.1 500 Internal Server Error
After patch
curl -I -H "Range: bytes=0-1023" http://localhost:8080/public.php/dav/files/<token>
HTTP/1.1 206 Partial Content
Content-Range: bytes 0-1023/<filesize>
Content-Length: 1024
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTriaged
Activity
hubimuc commentedon Dec 28, 2025
Please refer to issue: sabre-io/dav#1618
Kalle2018 commentedon Jun 5, 2026
Please look at this thread:
https://help.nextcloud.com/t/typeerror-desktop-version/232197
Why is the Bug not fixed?
The user "transdata" write there:
I got it! I’m just surprised that not everyone has this problem. In /3rdparty/sabre/dav/lib/DAV/CorePlugin.php, the following needs to be added or replaced on line 179:
if (is_resource($body) && (!stream_get_meta_data($body)[‘seekable’] || -1 === fseek($body, $start, SEEK_SET))) {
The specified code section in the httpGet method attempts to retrieve the file type (Content-Type) of a stream. The error is that the code calls stream_get_meta_data() directly on the stream handle ($body) without first checking whether $body is actually a stream.
The error occurs because $body can sometimes be a stream handle (Resource) and sometimes a string (when the HTTP method is HEAD). However, the stream_get_meta_data() function introduced in PHP 7 always expects a stream handle.
The fix is to ensure that $body is a valid stream before calling stream_get_meta_data(), or to use the correct function for strings if it is a string.
Since the code already ensures that $body is either a stream handle or an empty string (‘’), only one additional check needs to be added.
susnux commentedon Dec 2, 2026
Thanks for the detailed analysis! This was fixed upstream in sabre/dav 4.7.1, where Range headers are now ignored for non-GET requests (sabre-io/dav#1618). Nextcloud still ships 4.7.0; the update is pending in #62405 / #63032, with backports in #67025, #67026 and #67027, so this will be resolved once those are merged.