{"record":{"id":"2c9c94ffb480b6ba","repo":"passbolt/passbolt_api","slug":"the-identifier-should-be-a-valid-uuid-2c9c94","errorCode":null,"errorMessage":"The identifier should be a valid UUID.","messagePattern":"The identifier should be a valid UUID\\.","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"plugins/PassboltEe/PasswordExpiryPolicies/src/Service/Resources/PasswordExpiryPoliciesResourcesExpiryUpdateService.php","lineNumber":84,"sourceCode":"\n    /**\n     * @param array $data payload\n     * @return array<string, \\Cake\\I18n\\DateTime|null> array with the resourceIds as keys and the expiry date as value\n     * @throws \\Cake\\Http\\Exception\\BadRequestException if the expired value are not valid\n     * @throws \\Cake\\Http\\Exception\\BadRequestException if the resource_id value are not valid\n     * @throws \\Cake\\Http\\Exception\\BadRequestException if the resource_id value is found twice in the payload\n     * @throws \\Cake\\Http\\Exception\\BadRequestException if the sanitized array is empty\n     */\n    protected function validateAndParsePayload(array $data): array\n    {\n        $dataSanitized = [];\n        foreach ($data as $resource) {\n            if (!is_array($resource)) {\n                throw new BadRequestException(__('An array of arrays is expected.'));\n            }\n            $resourceId = $resource['id'] ?? null;\n            if (!Validation::uuid($resourceId)) {\n                throw new BadRequestException(__('The identifier should be a valid UUID.'));\n            }\n            $isExpiredDefined = array_key_exists('expired', $resource);\n            if (!$isExpiredDefined) {\n                throw new BadRequestException(__('The expiry date is required.'));\n            }\n            $expiryDate = $resource['expired'];\n            if (array_key_exists($resourceId, $dataSanitized)) {\n                throw new BadRequestException(__('The identifier should be unique: {0}.', $resourceId));\n            }\n            $dataSanitized[$resourceId] = is_null($expiryDate) ? $expiryDate : new DateTime($expiryDate);\n        }\n        if (empty($dataSanitized)) {\n            throw new BadRequestException(__('The data should not be empty.'));\n        }\n\n        return $dataSanitized;\n    }\n","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/PasswordExpiryPolicies/src/Service/Resources/PasswordExpiryPoliciesResourcesExpiryUpdateService.php#L66-L102","documentation":"In the bulk expiry update payload each resource entry must carry a 'id' field that is a valid UUID. validateAndParsePayload throws this BadRequestException when the id key is missing or fails CakePHP's Validation::uuid() check.","triggerScenarios":"Payload items with no 'id' key, an empty id, or a malformed id like '123' or 'resource-1' submitted to the resources expiry update endpoint.","commonSituations":"Hardcoded test IDs; reading IDs from a spreadsheet/export that truncated or reformatted them; confusing resource IDs with folder or permission IDs.","solutions":["Supply a valid v4 UUID in each item's 'id' field","Fetch real resource IDs from GET /resources.json first and use the 'id' field of each returned resource","Trim whitespace and re-check for copy/paste corruption of the UUID"],"exampleFix":"// before\ndata: [{\"id\": \"resource-123\", \"expired\": \"2026-01-01\"}]\n\n// after\ndata: [{\"id\": \"8e3874ae-4b40-590b-968a-418f70bdbb85\", \"expired\": \"2026-01-01\"}]","handlingStrategy":"validation","validationCode":"foreach ($data as $item) {\n    if (!isset($item['id']) || !\\Cake\\Validation\\Validation::uuid($item['id'])) {\n        throw new \\InvalidArgumentException(\"Invalid resource id: \" . json_encode($item['id'] ?? null));\n    }\n}","typeGuard":"function isUuid(mixed $id): bool {\n    return is_string($id) && \\Cake\\Validation\\Validation::uuid($id);\n}","tryCatchPattern":"try {\n    $service->updateMany($uac, $data);\n} catch (BadRequestException $e) {\n    if ($e->getMessage() === 'The identifier should be a valid UUID.') {\n        // fix payload ids and retry\n    }\n}","preventionTips":["Copy resource IDs from API responses, not by hand","Validate UUIDs with Validation::uuid() before calling the service","Store IDs as canonical lowercase UUID strings"],"tags":["passbolt","bad-request","uuid","validation"],"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"}