thephpleague/flysystem · error · RuntimeException

COPY command returned unexpected status code:

Error message

COPY command returned unexpected status code: 

What it means

Error "COPY command returned unexpected status code: " thrown in thephpleague/flysystem.

Source

Thrown at src/WebDAV/WebDAVAdapter.php:400

        }

        if ($this->manualCopy) {
            $this->manualCopy($source, $destination);

            return;
        }

        $this->createParentDirFor($destination);
        $location = $this->encodePath($this->prefixer->prefixPath($source));
        $newLocation = $this->encodePath($this->prefixer->prefixPath($destination));

        try {
            $response = $this->client->request('COPY', $location, null, [
                'Destination' => $this->client->getAbsoluteUrl($newLocation),
            ]);

            if ($response['statusCode'] < 200 || $response['statusCode'] >= 300) {
                throw new RuntimeException('COPY command returned unexpected status code: ' . $response['statusCode']);
            }
        } catch (Throwable $e) {
            throw UnableToCopyFile::fromLocationTo($source, $destination, $e);
        }
    }

    private function manualCopy(string $source, string $destination): void
    {
        try {
            $handle = $this->readStream($source);
            $this->writeStream($destination, $handle, new Config());
            @fclose($handle);
        } catch (Throwable $exception) {
            throw UnableToCopyFile::fromLocationTo($source, $destination, $exception);
        }
    }

    private function propsIsDirectory(array $properties): bool

View on GitHub (pinned to b277b5dc3d)

When it happens

Trigger: Thrown at src/WebDAV/WebDAVAdapter.php:400 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of thephpleague/flysystem@b277b5dc3d (2026-08-17). Data as JSON: /api/errors/25c5ff62bf2ed95c. Report an issue: GitHub.