{"record":{"id":"6b0abe1f5649b80b","repo":"passbolt/passbolt_api","slug":"information-about-the-key-is-required","errorCode":null,"errorMessage":"Information about the key is required.","messagePattern":"Information about the key is required\\.","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"plugins/PassboltEe/Sso/src/Controller/Keys/SsoKeysCreateController.php","lineNumber":36,"sourceCode":"\nuse App\\Controller\\AppController;\nuse Cake\\Http\\Exception\\BadRequestException;\nuse Passbolt\\Sso\\Service\\SsoKeys\\SsoKeysCreateService;\n\nclass SsoKeysCreateController extends AppController\n{\n    /**\n     * Create SSO Passphrase Key\n     *\n     * @throws \\App\\Error\\Exception\\ValidationException if data do not validate\n     * @throws \\Cake\\Http\\Exception\\InternalErrorException if saving data is not possible\n     * @return void\n     */\n    public function create(): void\n    {\n        $data = $this->request->getData();\n        if (!isset($data) || !is_array($data) || !count($data)) {\n            throw new BadRequestException(__('Information about the key is required.'));\n        }\n\n        $uac = $this->User->getAccessControl();\n        $key = (new SsoKeysCreateService())->create($uac, $data);\n\n        $this->success(__('The operation was successful'), $key);\n    }\n}\n","sourceCodeStart":18,"sourceCodeEnd":45,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/Sso/src/Controller/Keys/SsoKeysCreateController.php#L18-L45","documentation":"Thrown by SsoKeysCreateController::create() when the request body is empty, not an array, or contains zero items. Creating an SSO server key requires key metadata (e.g. certificate data) in the POST payload; an empty body cannot be processed.","triggerScenarios":"POST /sso/keys with no body, an empty JSON object {}, or a payload that CakePHP fails to parse into an array.","commonSituations":"Client sent JSON without Content-Type: application/json so getData() returns empty; forgot to serialize the key payload; framework stripped the body due to middleware or size limits.","solutions":["Send a non-empty JSON body with the key data, e.g. {\"certificate\": \"...\"}","Set Content-Type: application/json on the request","Inspect the serialized request body to ensure it isn't stripped by a proxy or client library","Confirm the correct HTTP method (POST) and endpoint are used"],"exampleFix":"// before\nawait api.post('/sso/keys');\n// after\nawait api.post('/sso/keys', {certificate: serverKeyCertificatePem}, {headers:{'Content-Type':'application/json'}});","handlingStrategy":"validation","validationCode":"const payload = {certificate: certPem};\nif (!payload || typeof payload !== 'object' || Object.keys(payload).length === 0) {\n  throw new Error('SSO key payload must be a non-empty object');\n}","typeGuard":"function isNonEmptyObject(v: unknown): v is Record<string, unknown> {\n  return typeof v === 'object' && v !== null && Object.keys(v).length > 0;\n}","tryCatchPattern":"try {\n  await createSsoKey(payload);\n} catch (e) {\n  if (e.response?.status === 400 && e.response?.data?.message?.includes('Information about the key is required')) {\n    // fix serialization / Content-Type and retry\n  }\n}","preventionTips":["Always send a JSON object body with Content-Type: application/json","Verify proxies/middleware don't strip request bodies","Unit-test the serialization of the key payload"],"tags":["sso","bad-request","empty-payload"],"backgroundTag":"empty-required-field","analyzedSha":"31c1bbc10f32808a607fa9bd81891e898779c0bc","analyzedAt":"2026-09-17T00:04:38.960Z","contentChangedAt":"2026-09-17T00:04:38.960Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}