{"record":{"id":"1b466ed1c3e9f57e","repo":"thephpleague/flysystem","slug":"unable-to-get-checksum-for-path-reason-1b466e","errorCode":null,"errorMessage":"Unable to get checksum for $path: $reason","messagePattern":"Unable to get checksum for \\$path: \\$reason","errorType":"exception","errorClass":"UnableToProvideChecksum","httpStatus":null,"severity":"error","filePath":"src/AzureBlobStorage/AzureBlobStorageAdapter.php","lineNumber":362,"sourceCode":"    {\n        $location = $this->prefixer->prefixPath($path);\n\n        return $this->client->getBlobUrl($this->container, $location);\n    }\n\n    public function checksum(string $path, Config $config): string\n    {\n        $algo = $config->get('checksum_algo', 'md5');\n\n        if ($algo !== 'md5') {\n            throw new ChecksumAlgoIsNotSupported();\n        }\n\n        try {\n            $metadata = $this->fetchMetadata($this->prefixer->prefixPath($path));\n            $checksum = $metadata->extraMetadata()['md5_checksum'] ?? '__not_specified';\n        } catch (Throwable $exception) {\n            throw new UnableToProvideChecksum($exception->getMessage(), $path, $exception);\n        }\n\n        if ($checksum === '__not_specified') {\n            throw new UnableToProvideChecksum('No checksum provided in metadata', $path);\n        }\n\n        return bin2hex(base64_decode($checksum));\n    }\n\n    public function temporaryUrl(string $path, DateTimeInterface $expiresAt, Config $config): string\n    {\n        if ( ! $this->serviceSettings instanceof StorageServiceSettings) {\n            throw UnableToGenerateTemporaryUrl::noGeneratorConfigured(\n                $path,\n                'The $serviceSettings constructor parameter must be set to generate temporary URLs.',\n            );\n        }\n","sourceCodeStart":344,"sourceCodeEnd":380,"githubUrl":"https://github.com/thephpleague/flysystem/blob/b277b5dc3d56650b68904117124e79c851e12376/src/AzureBlobStorage/AzureBlobStorageAdapter.php#L344-L380","documentation":"AzureBlobStorageAdapter::checksum() fetches blob properties via fetchMetadata() (Get Blob Properties REST call) and reads the md5_checksum extra field. Any Throwable raised during that fetch is wrapped as UnableToProvideChecksum with the Azure SDK's own message and the original exception chained. This is the generic failure path for Azure checksums.","triggerScenarios":"Checksumming a blob that does not exist (404), referencing a container name that is wrong or not provisioned, SAS token/shared-key credentials lacking read permission, network/DNS failure to the blob endpoint, or the path resolving to a directory prefix.","commonSituations":"Case-sensitive container/blob name mistakes; expired SAS tokens in background workers; environments pointing at the wrong storage account; checksum verification racing an upload that hasn't committed yet.","solutions":["Verify with $filesystem->fileExists($path) before checksumming.","Inspect $e->getPrevious() for the Azure SDK exception (ServiceException with 404/403 codes) and fix the account, container, or token scope.","Regenerate/extend SAS token validity and ensure it grants read (rc/r) on the container.","Catch UnableToProvideChecksum and distinguish by previous-exception code rather than string matching when you need specific handling."],"exampleFix":"// before\n$checksum = $filesystem->checksum('backups/latest.bak'); // blob deleted -> wraps 404\n\n// after\ntry {\n    $checksum = $filesystem->checksum('backups/latest.bak');\n} catch (UnableToProvideChecksum $e) {\n    $previous = $e->getPrevious();\n    if ($previous !== null && str_contains($previous->getMessage(), '404')) {\n        // blob missing: trigger re-upload instead of failing verification\n    } else {\n        throw $e;\n    }\n}","handlingStrategy":"try-catch","validationCode":"if ( ! $filesystem->fileExists($path)) {\n    throw new DomainException(\"Blob missing, cannot verify checksum: {$path}\");\n}","typeGuard":null,"tryCatchPattern":"use League\\Flysystem\\UnableToProvideChecksum;\n\ntry {\n    $md5 = $filesystem->checksum($path);\n} catch (UnableToProvideChecksum $e) {\n    $previous = $e->getPrevious(); // Azure SDK exception (often ServiceException)\n    $code = null;\n    if (method_exists($previous, 'getCode')) {\n        $code = $previous->getCode();\n    }\n    return match (true) {\n        $code === 404 => $onMissingBlob($path),\n        $code === 403 || $code === 401 => $onAuthFailure($path),\n        default => throw $e,\n    };\n}","preventionTips":["Scope SAS tokens to the container and operations (read) you actually need, with margin on expiry for long jobs.","Pin the correct account/container names via config, not string concatenation of user input.","Monitor chained previous-exception codes to alert on auth drift before it becomes an outage."],"tags":["php","flysystem","azure-blob-storage","checksum","not-found","sas-token"],"backgroundTag":"checksum-retrieval-failed","analyzedSha":"b277b5dc3d56650b68904117124e79c851e12376","analyzedAt":"2026-08-17T04:28:35.741Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}