passbolt/passbolt_api · error · SubscriptionException

The file could not be found.

Error message

The file {0} could not be found.

What it means

SubscriptionKeyImportService::importFromFile() first checks file_exists($fileName) and throws SubscriptionException if the license file cannot be found on disk. It fails before attempting any read or validation.

Solutions

  1. Verify the absolute path exists: ls -l /path/to/subscription_key.txt
  2. Pass an absolute path to the import command instead of a relative one
  3. Check container/volume mounts so the license file is visible where the command runs

Example fix

// before
$svc->importFromFile('subscription.txt', $uac);
// after
$path = CONFIG . 'subscription.txt';
if (!file_exists($path)) { throw new Exception("License file missing: $path"); }
$svc->importFromFile($path, $uac);
Defensive patterns

Strategy: validation

Validate before calling

if (!is_file($path)) { throw new InvalidArgumentException("License file not found: $path"); }

Type guard

null

Try / catch

try { $svc->importFromFile($path, $uac); } catch (SubscriptionException $e) { // check file path in message }

Prevention

When it happens

Trigger: Running the subscription import (command 'execute' -> importFromFile) with a file path that does not exist, e.g. a typo'd or relative path resolved against the wrong working directory.

Common situations: CLI import run from a different cwd than expected; license file uploaded to webroot but CLI references config path; container/volume not mounting the license file; filename with wrong extension or case (case-sensitive filesystems).

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17). Data as JSON: /api/errors/85859927f62ecaac. Report an issue: GitHub.

Appendix: source

Thrown at plugins/PassboltEe/Subscription/src/Service/Subscriptions/SubscriptionKeyImportService.php:37

use App\Utility\UserAccessControl;
use Passbolt\Subscription\Error\Exception\Subscriptions\SubscriptionException;
use Passbolt\Subscription\Model\Dto\SubscriptionKeyDto;

/**
 * Persists a subscription key supplied via file or text.
 */
class SubscriptionKeyImportService
{
    /**
     * @param string $fileName Path to a file containing the subscription key.
     * @param \App\Utility\UserAccessControl $uac UAC object.
     * @return \Passbolt\Subscription\Model\Dto\SubscriptionKeyDto
     * @throws \Passbolt\Subscription\Error\Exception\Subscriptions\SubscriptionException If the file or the contained subscription is not valid.
     */
    public function importFromFile(string $fileName, UserAccessControl $uac): SubscriptionKeyDto
    {
        if (!file_exists($fileName)) {
            throw new SubscriptionException(__('The file {0} could not be found.', $fileName));
        }
        if (!is_readable($fileName)) {
            throw new SubscriptionException(__('The file {0} could not be read.', $fileName));
        }
        $subscription = file_get_contents($fileName);
        if (!$subscription) {
            throw new SubscriptionException(__('The file {0} could not be read.', $fileName));
        }

        return $this->import($subscription, $uac);
    }

    /**
     * @param string|null $subscription Raw subscription key payload (Base64).
     * @param \App\Utility\UserAccessControl $uac UAC object.
     * @return \Passbolt\Subscription\Model\Dto\SubscriptionKeyDto
     * @throws \Passbolt\Subscription\Error\Exception\Subscriptions\SubscriptionException If the subscription is not valid.
     */

View on GitHub (pinned to 31c1bbc10f)