{"record":{"id":"74e7e2e2129b179e","repo":"passbolt/passbolt_api","slug":"the-private-key-identifier-should-be-a-uuid","errorCode":null,"errorMessage":"The private key identifier should be a UUID.","messagePattern":"The private key identifier should be a UUID\\.","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"plugins/PassboltCe/Metadata/src/Controller/MetadataPrivateKeysUpdateController.php","lineNumber":38,"sourceCode":"use Cake\\Http\\Exception\\BadRequestException;\nuse Cake\\Validation\\Validation;\nuse Passbolt\\Metadata\\Service\\MetadataPrivateKeysUpdateService;\n\nclass MetadataPrivateKeysUpdateController extends AppController\n{\n    /**\n     * Update a user private key\n     *\n     * @param string $id private key id\n     * @return void\n     */\n    public function update(string $id)\n    {\n        $this->assertJson();\n        $this->assertNotEmptyArrayData();\n\n        if (!Validation::uuid($id)) {\n            throw new BadRequestException(__('The private key identifier should be a UUID.'));\n        }\n        $data = $this->request->getData();\n\n        $updated = (new MetadataPrivateKeysUpdateService())->update($this->User->getAccessControl(), $id, $data);\n        $this->success(__('The operation was successful.'), $updated);\n    }\n}\n","sourceCodeStart":20,"sourceCodeEnd":46,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/Metadata/src/Controller/MetadataPrivateKeysUpdateController.php#L20-L46","documentation":"UUID guard in MetadataPrivateKeysUpdateController::update(): the {id} path segment must be a valid UUID of the metadata private key record to update. Fires when the client passes a malformed identifier, so the update is aborted with HTTP 400 before touching the service layer. A syntactically valid UUID that does not exist is handled later as a not-found error.","triggerScenarios":"Updating a metadata private key where {id} is not a valid UUID (e.g. a user id or key fingerprint was used).","commonSituations":"Confusing the metadata private key id with the user id or metadata key id; stale/hand-edited URLs; scripts iterating wrong id field.","solutions":["Use the metadata private key UUID (from GET /metadata/private-keys or key detail responses).","Resolve the correct id via the API before updating.","Add UUID validation client-side."],"exampleFix":"// before\nput(`/metadata/private-keys/${userId}`, data);\n// after\nput(`/metadata/private-keys/${privateKeyId}`, data);","handlingStrategy":"validation","validationCode":"if (!isUuid(privateKeyId)) throw new Error('private key id must be a UUID');","typeGuard":"function isUuid(v) { return typeof v === 'string' && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(v); }","tryCatchPattern":"try { await api.put(`/metadata/private-keys/${privateKeyId}`, data); } catch (e) { if (e.response?.status === 400 && String(e.message).includes('UUID')) { privateKeyId = await resolvePrivateKeyId(); return retry(); } throw e; }","preventionTips":["Use the private key entity's own id, not the user or key id.","Validate ids before interpolating into URLs.","Cache resolved ids from API responses."],"tags":["uuid","validation","api","bad-request"],"backgroundTag":"invalid-identifier-format","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"}