passbolt/passbolt_api · error · BadRequestException
Service provider invalid.
Error message
Service provider invalid.
What it means
Thrown by SsoSettingsSetService::getSsoSettingsForm when the 'provider' field is present but is not a string (e.g. an array, integer, or null-like value). The provider must be a string identifier to look up the correct form class.
Solutions
- Send provider as a plain string, e.g. "provider": "azure".
- Check the client serialization so the provider value is not wrapped in an object/array.
- Cast/normalize on the client side before sending (String(provider)).
Example fix
// before
"provider": { "id": "azure" }
// after
"provider": "azure" Defensive patterns
Strategy: type-guard
Validate before calling
if (isset($payload['provider']) && !is_string($payload['provider'])) { throw new \TypeError('provider must be a string'); } Type guard
function isStringProvider($p): bool { return is_string($p) && $p !== ''; } Prevention
- Send provider as a JSON string, never a number or object.
- Avoid PHP loose-typing surprises in client code (declare strict_types).
- Test payload serialization before calling the API.
When it happens
Trigger: POST/PUT /sso/settings with provider set to a non-string value, e.g. {"provider": 123} or {"provider": {"name": "azure"}}.
Common situations: Client code passing an enum/number instead of its string name; JSON payload built programmatically with wrong types; form submissions sending provider as an array.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Service provider missing.
- Service provider not supported.
- The SSO state is invalid.
- The SSO state is invalid. The SSO state is expired.
- Ajax/Json request not supported.
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/28121f8d0ce5e35c.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/PassboltEe/Sso/src/Service/SsoSettings/SsoSettingsSetService.php:154
$msg .= $exception->getMessage();
throw new InternalErrorException($msg, 500, $exception);
}
}
return $gpg->encrypt($jsonData, true);
}
/**
* @param array $data payload
* @return \Passbolt\Sso\Form\BaseSsoSettingsForm
*/
protected function getSsoSettingsForm(array $data): BaseSsoSettingsForm
{
if (!isset($data['provider'])) {
throw new BadRequestException('Service provider missing.');
}
if (!is_string($data['provider'])) {
throw new BadRequestException('Service provider invalid.');
}
if (!in_array($data['provider'], SsoSetting::ALLOWED_PROVIDERS)) {
throw new BadRequestException('Service provider not supported.');
}
switch ($data['provider']) {
case SsoSetting::PROVIDER_AZURE:
return new SsoSettingsAzureDataForm();
case SsoSetting::PROVIDER_GOOGLE:
return new SsoSettingsGoogleDataForm();
case SsoSetting::PROVIDER_OAUTH2:
return new SsoSettingsOAuth2DataForm();
case SsoSetting::PROVIDER_ADFS:
return new SsoSettingsAdfsDataForm();
case SsoSetting::PROVIDER_PINGONE:
return new SsoSettingsPingOneDataForm();
default:
throw new BadRequestException('Service provider not supported.');View on GitHub (pinned to 31c1bbc10f)