passbolt/passbolt_api · error · BadRequestException

Invalid status.

Error message

Invalid status.

What it means

assertActiveStatus() requires $data['status'] to be present and exactly equal to SsoSetting::STATUS_ACTIVE ('active'). Missing or different values trigger a BadRequestException 'Invalid status.' This gates the activation payload contract.

Solutions

  1. Send exactly ['status' => 'active'] (SsoSetting::STATUS_ACTIVE) in the activation payload
  2. Use the SsoSetting::STATUS_ACTIVE constant instead of a hardcoded string
  3. Whitelist/normalize client input to lowercase before calling activate()

Example fix

// before
$service->activate($uac, $id, ['token' => $token, 'status' => $input['Status']]);
// after
$service->activate($uac, $id, ['token' => $token, 'status' => SsoSetting::STATUS_ACTIVE]);
Defensive patterns

Strategy: validation

Validate before calling

if (($data['status'] ?? null) !== SsoSetting::STATUS_ACTIVE) { throw new \InvalidArgumentException('status must be "active"'); }

Try / catch

try { $service->activate($uac, $id, $data); } catch (BadRequestException $e) { // normalize payload and retry once }

Prevention

When it happens

Trigger: Calling activate() with no 'status' key, a typo like 'Active'/'actived', an empty string, or sending the whole settings entity where status holds a different value.

Common situations: API clients omitting the status field in the PATCH-style activation payload; case-sensitivity mistakes after refactoring; building the payload from user input without whitelisting.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at plugins/PassboltEe/Sso/src/Service/SsoSettings/SsoSettingsActivateService.php:148

            throw new NotFoundException(__('The SSO setting does not exist.'), 404, $exception);
        }

        if ($ssoSettings->status !== $status) {
            throw new BadRequestException(__('The settings status is invalid.'));
        }

        return $ssoSettings;
    }

    /**
     * @param array $data user provided data
     * @throws \Cake\Http\Exception\BadRequestException if status is invalid
     * @return void
     */
    protected function assertActiveStatus(array $data): void
    {
        if (!isset($data['status']) || $data['status'] !== SsoSetting::STATUS_ACTIVE) {
            throw new BadRequestException(__('Invalid status.'));
        }
    }
}

View on GitHub (pinned to 31c1bbc10f)