Undefined array key 1 at /var/www/nextcloud/apps/dav/lib/BulkUpload/MultipartRequestParser.php#183

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:


Or for longer, use three backticks above and below the code snippet:


Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version: 26.0.3
Operating system and version: Ubuntu 22.04.2
Apache or nginx version: Apache 2.4.52
PHP version: PHP 8.1.2

The issue you are facing:

Is this the first time you’ve seen this error?: Yes

Steps to replicate it:

  1. Everything seems to be running fine from a user’s perspective.
  2. Log in to Nextcloud & open the Administrator Logging page.
  3. Read log.

The output of your Nextcloud log in Admin > Logging: (I abbreviated this. There are somewhat regular entries regarding locked files. The screen is full of this basic pattern.)

Error	PHP	Undefined array key 1 at /var/www/nextcloud/apps/dav/lib/BulkUpload/MultipartRequestParser.php#183	
Error	PHP	Undefined array key 1 at /var/www/nextcloud/apps/dav/lib/BulkUpload/MultipartRequestParser.php#183	
Error	PHP	Undefined array key 1 at /var/www/nextcloud/apps/dav/lib/BulkUpload/MultipartRequestParser.php#183	
Error	PHP	Undefined array key 1 at /var/www/nextcloud/apps/dav/lib/BulkUpload/MultipartRequestParser.php#183	
Error	PHP	Undefined array key 1 at /var/www/nextcloud/apps/dav/lib/BulkUpload/MultipartRequestParser.php#183	
Error	PHP	Undefined array key 1 at /var/www/nextcloud/apps/dav/lib/BulkUpload/MultipartRequestParser.php#183	
Error	PHP	Undefined array key 1 at /var/www/nextcloud/apps/dav/lib/BulkUpload/MultipartRequestParser.php#183	
Error	PHP	Undefined array key 1 at /var/www/nextcloud/apps/dav/lib/BulkUpload/MultipartRequestParser.php#183	
Error	PHP	Undefined array key 1 at /var/www/nextcloud/apps/dav/lib/BulkUpload/MultipartRequestParser.php#183	
Error	PHP	Undefined array key 1 at /var/www/nextcloud/apps/dav/lib/BulkUpload/MultipartRequestParser.php#183	
Error	PHP	Undefined array key 1 at /var/www/nextcloud/apps/dav/lib/BulkUpload/MultipartRequestParser.php#183

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

$CONFIG = array (
  'instanceid' => 'XXXXXXXXXXXXXXXXXXX',
  'passwordsalt' => 'XXXXXXXXXXXXXXXXXXX',
  'trusted_domains' =>
  array (
    0 => 'XXXXXXXX.com',
    1 => 'XXXXXXXXXXX',
    2 => 'localhost',
    3 => 'www.XXXXXXXXXXX.com',
    4 => 'cloud.XXXXXXXXXXXXXXXXXX.com',
  'datadirectory' => '/home/nextcloud/data',
  'overwrite.cli.url' => 'https://XXXXXXXXXXXXXXXXX.com/nextcloud',
  'htaccess.RewriteBase' => '/nextcloud',
  'dbtype' => 'mysql',
  'version' => '',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'XXXXXXXXXX',
  'dbpassword' => 'XXXXXXXXXXXXXX',
  'logtimezone' => 'UTC',
  'default_phone_region' => 'US',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'mail_domain' => 'XXXXXXXXX.com',
  'mail_from_address' => 'XXXXXXXX',
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'tls',
  'mail_smtpauthtype' => 'PLAIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'XXXXXXXXXX.XXXXXXXX.com',
  'mail_smtpport' => '587',
  'mail_smtpname' => 'XXXXXXXXX@XXXXXXXXX.com',
  'mail_smtppassword' => 'XXXXXXXXXXXXXXX',
  'auth.bruteforce.protection.enabled' => true,
  'updater.release.channel' => 'stable',
  'check_for_working_wellknown_setup' => true,
  'check_for_working_htaccess' => true,
  'app_install_overwrite' =>
  array (
    0 => 'calendar',
    1 => 'ownpad',
    2 => 'sharerenamer',
  'mysql.utf8mb4' => true,
  'encryption.legacy_format_support' => false,
  'encryption.key_storage_migrated' => false,
  'data-fingerprint' => 'XXXXXXXXXXXXXXXX',
  'memories.exiftool' => '/var/www/nextcloud/apps/memories/exiftool-bin/exiftool-amd64-glibc',
  'memories.vod.path' => '/var/www/nextcloud/apps/memories/exiftool-bin/go-vod-amd64',
  'memories.vod.ffmpeg' => '/usr/bin/ffmpeg',
  'memories.vod.ffprobe' => '/usr/bin/ffprobe',

The output of your Apache/nginx/system log in /var/log/____: /var/log/syslog

[Pasted here](https://privatebin.net/?062dd9d07c4ab7fc#46taBBdigppyzghAoUQL9yaSwbQUSS2XNch2wVyup71k)

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

[Pasted here](https://privatebin.net/?ef09c6fb595524f3#73Ro6Lx4UqXiKLbYPET39Xg3xYLmQZrshSrq4diW9ZFL)

I checked the MultipartRequestParser.php file and here are the contents:

 * @copyright Copyright (c) 2021, Louis Chemineau <louis@chmn.me>
 * @author Louis Chemineau <louis@chmn.me>
 * @license AGPL-3.0
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * GNU Affero General Public License for more details.
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>

namespace OCA\DAV\BulkUpload;

use Sabre\HTTP\RequestInterface;
use Sabre\DAV\Exception;
use Sabre\DAV\Exception\BadRequest;
use Sabre\DAV\Exception\LengthRequired;
use OCP\AppFramework\Http;

class MultipartRequestParser {

	/** @var resource */
	private $stream;

	/** @var string */
	private $boundary = "";

	/** @var string */
	private $lastBoundary = "";

	 * @throws BadRequest
	public function __construct(RequestInterface $request) {
		$stream = $request->getBody();
		$contentType = $request->getHeader('Content-Type');

		if (!is_resource($stream)) {
			throw new BadRequest('Body should be of type resource');

		if ($contentType === null) {
			throw new BadRequest("Content-Type can not be null");

		$this->stream = $stream;

		$boundary = $this->parseBoundaryFromHeaders($contentType);
		$this->boundary = '--'.$boundary."\r\n";
		$this->lastBoundary = '--'.$boundary."--\r\n";

	 * Parse the boundary from the Content-Type header.
	 * Example: Content-Type: "multipart/related; boundary=boundary_bf38b9b4b10a303a28ed075624db3978"
	 * @throws BadRequest
	private function parseBoundaryFromHeaders(string $contentType): string {
		try {
			[$mimeType, $boundary] = explode(';', $contentType);
			[$boundaryKey, $boundaryValue] = explode('=', $boundary);
		} catch (\Exception $e) {
			throw new BadRequest("Error while parsing boundary in Content-Type header.", Http::STATUS_BAD_REQUEST, $e);

		$boundaryValue = trim($boundaryValue);

		// Remove potential quotes around boundary value.
		if (substr($boundaryValue, 0, 1) == '"' && substr($boundaryValue, -1) == '"') {
			$boundaryValue = substr($boundaryValue, 1, -1);

		if (trim($mimeType) !== 'multipart/related') {
			throw new BadRequest('Content-Type must be multipart/related');

		if (trim($boundaryKey) !== 'boundary') {
			throw new BadRequest('Boundary is invalid');

		return $boundaryValue;

	 * Check whether the stream's cursor is sitting right before the provided string.
	 * @throws Exception
	private function isAt(string $expectedContent): bool {
		$expectedContentLength = strlen($expectedContent);

		$content = fread($this->stream, $expectedContentLength);
		if ($content === false) {
			throw new Exception('An error occurred while checking content');

		$seekBackResult = fseek($this->stream, -$expectedContentLength, SEEK_CUR);
		if ($seekBackResult === -1) {
			throw new Exception("Unknown error while seeking content", Http::STATUS_INTERNAL_SERVER_ERROR);

		return $expectedContent === $content;

	 * Check whether the stream's cursor is sitting right before the boundary.
	private function isAtBoundary(): bool {
		return $this->isAt($this->boundary);

	 * Check whether the stream's cursor is sitting right before the last boundary.
	public function isAtLastBoundary(): bool {
		return $this->isAt($this->lastBoundary);

	 * Parse and return the next part of the multipart headers.
	 * Example:
	 * --boundary_azertyuiop
	 * Header1: value
	 * Header2: value
	 * Content of
	 * the part
	public function parseNextPart(): array {

		$headers = $this->readPartHeaders();

		$content = $this->readPartContent($headers["content-length"], $headers["x-file-md5"]);

		return [$headers, $content];

	 * Read the boundary and check its content.
	 * @throws BadRequest
	private function readBoundary(): string {
		if (!$this->isAtBoundary()) {
			throw new BadRequest("Boundary not found where it should be.");

		return fread($this->stream, strlen($this->boundary));

	 * Return the headers of a part of the multipart body.
	 * @throws Exception
	 * @throws BadRequest
	 * @throws LengthRequired
	private function readPartHeaders(): array {
		$headers = [];

		while (($line = fgets($this->stream)) !== "\r\n") {
			if ($line === false) {
				throw new Exception('An error occurred while reading headers of a part');

			try {
				[$key, $value] = explode(':', $line, 2);
				$headers[strtolower(trim($key))] = trim($value);
			} catch (\Exception $e) {
				throw new BadRequest('An error occurred while parsing headers of a part', Http::STATUS_BAD_REQUEST, $e);

		if (!isset($headers["content-length"])) {
			throw new LengthRequired("The Content-Length header must not be null.");

		if (!isset($headers["x-file-md5"])) {
			throw new BadRequest("The X-File-MD5 header must not be null.");

		return $headers;

	 * Return the content of a part of the multipart body.
	 * @throws Exception
	 * @throws BadRequest
	private function readPartContent(int $length, string $md5): string {
		$computedMd5 = $this->computeMd5Hash($length);

		if ($md5 !== $computedMd5) {
			throw new BadRequest("Computed md5 hash is incorrect.");

		$content = stream_get_line($this->stream, $length);

		if ($content === false) {
			throw new Exception("Fail to read part's content.");

		if (feof($this->stream)) {
			throw new Exception("Unexpected EOF while reading stream.");

		// Read '\r\n'.
		stream_get_contents($this->stream, 2);

		return $content;

	 * Compute the MD5 hash of the next x bytes.
	private function computeMd5Hash(int $length): string {
		$context = hash_init('md5');
		hash_update_stream($context, $this->stream, $length);
		fseek($this->stream, -$length, SEEK_CUR);
		return hash_final($context);

It might be helpful to note that this install was originally on Ubuntu 16.04 as Nextcloud 18 (or earlier?) and then upgraded to 18.04 where it was stuck on Nextcloud 20.x for quite some time. I finally migrated it to new hardware with a new OS a few months ago & upgraded it through the major versions to this point.

Any help with this would be appreciated.

Hi @MRPockets - Can you provide the raw stack trace form one of these entries? If move your mouse cursor to the far right while hovering over one of these entries, a clipboard icon should appear. Select “Copy RAW” and provide the output here. That will help determine where this is being called from.

Here it is:

{"reqId":"3Woxa9v5Rc68logp1fWz","level":3,"time":"2023-07-19T14:55:35+00:00","remoteAddr":"","user":"chris.best","app":"PHP","method":"POST","url":"/nextcloud/remote.php/dav/bulk","message":"Undefined array key 1 at /var/www/nextcloud/apps/dav/lib/BulkUpload/MultipartRequestParser.php#183","userAgent":"Mozilla/5.0 (Linux) mirall/3.9.0-20230616.170352.c6c6c61f5-1.0~jammy1 (Nextcloud, ubuntu-5.15.0-75-generic ClientArchitecture: x86_64 OsArchitecture: x86_64)","version":"","data":{"app":"PHP"},"id":"64b7f96810177"}

Looks like a bug that may have been hidden (somewhat) previously (earlier PHP versions didn’t consider it an error).

I don’t see any reports of that one in particular, but one that similar (and somewhat near it in the code base) is here:

I’d say it’s worth reporting in its own Issue.

I upgraded to Nextcloud 27.0.1 before I reported the issue and it does appear to be fixed in this version. I will report back if the issue returns.

Thank you for taking a look at it.

1 Like

I’m now on 28.0.2
on Debian
Operating System: Linux 5.10.0-27-amd64 x86_64

Is this the same kind of error?

How to solve?

I’m getting similar errors on my instance, NC 28.0.2.

Error	PHP	
Undefined array key 15131 at /var/www/nextcloud/apps/mail/lib/Cache/Cache.php#138 

Is someone already taking care of this :thinking:

Error occured for me in 28.0.3

Undefined array key 1 at /app/www/public/lib/private/Profile/Actions/FediverseAction.php#81

I just want to add that the amount of errors showing up latley are just mindblowing. What has changed since i never used to get errors and now i get tons of them.

I also have similar errors in my php, apart from the fact that after the update I am experiencing a drop in the performance of my nextcloud instance where it suddenly fails, it just keeps loading and after a while the 502 bad gateway error message comes and only returns if remote access and restart php.

My Operating System is an Ubuntu Server

Nextcloud 28.0.3
PHP 8.3

After upgrading to Nextcloud 28.0.4 i get a similar error:

[PHP] Fehler: Undefined array key 1 at /var/www/nextcloud/3rdparty/wapmorgan/mp3info/src/Mp3Info.php#1056
GET /nextcloud/core/preview?x=32&y=32&fileId=15919
von 94.31.xxx.yyy von $MyUserNAme um 02.04.2024, 21:39:01

Nextcloud Hub 7 (28.0.4)
nginx/1.25.4 (fpm-fcgi)
PHP 8.2.17
MariaDB 10.6.17

List of activated apps

 - activity: 2.20.0
 - admin_audit: 1.18.0
 - bookmarks: 13.1.3
 - bruteforcesettings: 2.8.0
 - calendar: 4.6.7
 - cloud_federation_api: 1.11.0
 - comments: 1.18.0
 - contacts: 5.5.3
 - contactsinteraction: 1.9.0
 - dav: 1.29.1
 - federatedfilesharing: 1.18.0
 - federation: 1.18.0
 - files: 2.0.0
 - files_reminders: 1.1.0
 - files_sharing: 1.20.0
 - files_trashbin: 1.18.0
 - files_versions: 1.21.0
 - groupfolders: 16.0.5
 - logreader: 2.13.0
 - lookup_server_connector: 1.16.0
 - nextcloud_announcements: 1.17.0
 - notes: 4.9.4
 - notifications: 2.16.0
 - oauth2: 1.16.3
 - password_policy: 1.18.0
 - phonetrack: 0.7.7
 - photos: 2.4.0
 - privacy: 1.12.0
 - provisioning_api: 1.18.0
 - related_resources: 1.3.0
 - serverinfo: 1.18.0
 - settings: 1.10.1
 - sharebymail: 1.18.0
 - support: 1.11.1
 - systemtags: 1.18.0
 - text: 3.9.1
 - theming: 2.3.0
 - twofactor_backupcodes: 1.17.0
 - updatenotification: 1.18.0
 - viewer: 2.2.0
 - workflowengine: 2.10.0
 - circles: 22.3.0
 - dashboard: 7.0.0
 - encryption
 - files_external: 1.12.0
 - files_pdfviewer: 2.9.0
 - files_rightclick: 1.6.0
 - firstrunwizard: 2.9.0
 - notify_push: 0.6.10
 - recommendations: 0.4.0
 - survey_client: 1.16.0
 - suspicious_login
 - twofactor_totp
 - user_ldap
 - user_status: 1.0.1
 - weather_status: 1.0.0

Is there a solution for this?


Hi folks - Every “Undefined array key” error has a completely different cause.

I’ve adjusted the subject of this old thread to avoid confusion.

Please created either dedicated posts or issues for your matters with the full stack trace (raw log entry) for your individual situations.

Without a stack trace (i.e. the full log entry + in some cases an entry just before or after), it’s impossible to look into any of these situations.

@Witzker & @rcjca Your situations look to match each other and like something in the Mail app. Looks like this one.

@jonas740 Errors like this are, in part, increasing because PHP 8.x has been upping the logging severity of various situations in each release. Previously a lot of these situations would only pop up if you enabled extra debugging/logging. For your specific situation, it appears to be this one.

@Edson_Barbosa I suggest creating a dedicated post for your situation. More information will be needed.

@Tuffiglig Your situation happens to look similar, though not the same, as one I recently worked on here. In your case, it looks like you might have an mp3 file that may corrupted or somehow otherwise unexpected headers. This error is coming from a third-party dependency. The best Nextcloud Server can do is skip generating a preview for the file. But there does look like there is an opportunity to help the third-party library maybe improve their error handling in that area of code. You may be able to figure out which file it is, by going to to a URL like https://domain.tld/index.php/f/{fileId} (15919 in the log entry you posted).

Thank you for the detailed answer, @jtr

After i wrote my post in this thread, i emptied my logfile to hunt another bug.
I am not able to recreate the error.
Tried it with

occ files:scan --all
occ files:scan-app-data

When i try your link with my domain and my file-id, it shows this URL:

Maybe it was an upgrade fault from nc 27.1.8 to 28.0.4.

I will keep an eye on it


1 Like

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.