{"record":{"id":"f33543627963a667","repo":"passbolt/passbolt_api","slug":"the-metadata-session-key-data-is-identical","errorCode":null,"errorMessage":"The metadata session key data is identical.","messagePattern":"The metadata session key data is identical\\.","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"info","filePath":"plugins/PassboltCe/Metadata/src/Service/MetadataSessionKeyUpdateService.php","lineNumber":80,"sourceCode":"        $data = $form->getData();\n\n        /** @var \\Passbolt\\Metadata\\Model\\Table\\MetadataSessionKeysTable $metadataSessionKeysTable */\n        $metadataSessionKeysTable = $this->fetchTable('Passbolt/Metadata.MetadataSessionKeys');\n\n        try {\n            /** @var \\Passbolt\\Metadata\\Model\\Entity\\MetadataSessionKey $metadataSessionKey */\n            $metadataSessionKey = $metadataSessionKeysTable\n                ->find()\n                ->where(['id' => $id, 'user_id' => $uac->getId()])\n                ->firstOrFail();\n        } catch (RecordNotFoundException $e) {\n            // 404 session key entry does not exist or not for current user_id\n            throw new NotFoundException(__('The metadata session key does not exist or does not belong to this user.'));\n        }\n\n        // 400 no changes to be made\n        if ($data['data'] === $metadataSessionKey->get('data')) {\n            throw new BadRequestException(__('The metadata session key data is identical.'));\n        }\n        // 409 if the modified date is not equal to the persisted session key one\n        $asserTime = (new DateTime($data['modified']))->diffInSeconds($metadataSessionKey->get('modified')) === 0;\n        if (!$asserTime) {\n            throw new ConflictException(__('The metadata session key data has changed.'));\n        }\n\n        $metadataSessionKey = $metadataSessionKeysTable->patchEntity(\n            $metadataSessionKey,\n            ['data' => $data['data']],\n            ['accessibleFields' => ['data' => true]]\n        );\n\n        try {\n            /** @var \\Passbolt\\Metadata\\Model\\Entity\\MetadataSessionKey $updatedEntity */\n            $updatedEntity = $metadataSessionKeysTable->saveOrFail($metadataSessionKey);\n        } catch (PersistenceFailedException $exception) { // @phpstan-ignore-line\n            // 400 openpgp data does not validate, for example it's not for the current user","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/Metadata/src/Service/MetadataSessionKeyUpdateService.php#L62-L98","documentation":"No-op guard in MetadataSessionKeyUpdateService::update(): the submitted session key data is byte-identical to the stored record, so the update would change nothing and a conflict is raised rather than performing a redundant write.","triggerScenarios":"Client re-sends the same encrypted payload without modification, or retries an already-applied update with identical content.","commonSituations":"Idempotent retry logic re-POSTing the same body, cron jobs refreshing keys unconditionally, generating the same armored message from unchanged plaintext.","solutions":["Compute the new payload only when the underlying key/plaintext changed","Check the existing value before calling update and skip if identical","Treat this 400 as a no-op success in idempotent pipelines"],"exampleFix":"// before\n$service->update($uac, $id, ['data' => $same, 'modified' => $modified]);\n// after\nif ($same !== $existing->get('data')) { $service->update($uac, $id, ['data' => $same, 'modified' => $modified]); }","handlingStrategy":"validation","validationCode":"if ($newData === $existingKey->get('data')) { return; } // skip no-op update","typeGuard":null,"tryCatchPattern":"try { $service->update($uac, $id, $data); } catch (BadRequestException $e) { /* identical data: treat as no-op */ }","preventionTips":["Compare payloads before sending updates","Skip no-op writes in retry/cron logic","Only rotate session keys when the underlying key material changes"],"tags":["no-op","bad-request","idempotency","metadata-session-key"],"backgroundTag":"invalid-argument-value","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"}