{"record":{"id":"d4343afa0115911e","repo":"passbolt/passbolt_api","slug":"the-resource-identifier-should-be-a-valid-uuid-d4343a","errorCode":null,"errorMessage":"The resource identifier should be a valid UUID.","messagePattern":"The resource identifier should be a valid UUID\\.","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"src/Controller/Secrets/SecretsViewController.php","lineNumber":73,"sourceCode":"        $this->Resources = $this->fetchTable('Resources');\n    }\n\n    /**\n     * Secret View action\n     *\n     * @param string $resourceId uuid Identifier of the resource\n     * @throws \\Cake\\Http\\Exception\\BadRequestException if the resource id is not a uuid\n     * @throws \\Cake\\Http\\Exception\\NotFoundException if the user has no current READ access on the resource\n     * @throws \\Cake\\Http\\Exception\\NotFoundException if the user does not have a secret for the resource\n     * @return void\n     */\n    public function view(string $resourceId)\n    {\n        $this->assertJson();\n\n        // Check request sanity\n        if (!Validation::uuid($resourceId)) {\n            throw new BadRequestException(__('The resource identifier should be a valid UUID.'));\n        }\n\n        $uac = $this->User->getAccessControl();\n\n        // Defence in depth: reject the read if the caller no longer has permission on the resource\n        $hasAccess = $this->Resources->Permissions->hasAccess(\n            PermissionsTable::RESOURCE_ACO,\n            $resourceId,\n            $uac->getId(),\n            Permission::READ\n        );\n        if (!$hasAccess) {\n            throw new NotFoundException(__('The secret does not exist.'));\n        }\n\n        // Retrieve the secret.\n        /** @var \\App\\Model\\Entity\\Secret $secret */\n        $secret = $this->Secrets->findByResourceUser($resourceId, $uac->getId())->first();","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Controller/Secrets/SecretsViewController.php#L55-L91","documentation":"Thrown by SecretsViewController::view() when the resourceId path parameter is not a valid UUID (Validation::uuid() fails). This is the first request-sanity check for GET /secrets/resource/{resourceId}, rejecting malformed identifiers as 400 Bad Request before any permission or database work.","triggerScenarios":"GET /secrets/resource/<id>.json with a non-UUID <id>: a resource name, numeric database key, URL-encoded garbage, or a truncated/typo'd id.","commonSituations":"Clients storing resource ids in the wrong column (e.g. slug); copy-paste losing characters; mixing up resource id with secret id; legacy code using incrementing ids.","solutions":["Validate the resource id is a UUID before calling GET /secrets/resource/{id}.json","Fetch resource ids from GET /resources.json rather than constructing them","Check the client is not substituting the secret id or another entity's id","Fix string interpolation/truncation in the URL builder"],"exampleFix":"// before\nconst secret = await api.get(`/secrets/resource/${resource.slug}.json`);\n// after\nif (!isUuid(resource.id)) throw new Error(`invalid resource id: ${resource.id}`);\nconst secret = await api.get(`/secrets/resource/${resource.id}.json`);","handlingStrategy":"validation","validationCode":"const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\nif (!UUID_RE.test(resourceId)) throw new Error(`invalid resource id: ${resourceId}`);","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.get(`/secrets/resource/${resourceId}.json`); }\ncatch (e) { if (e.response?.status === 400 && /UUID/.test(e.response?.data?.message ?? '')) { /* fix id source, do not retry blindly */ } }","preventionTips":["Keep resource ids from API responses only (GET /resources.json), never derive them","Distinguish resource id vs secret id vs metadata id in your client model","Validate path parameters with a UUID guard before requests","Watch for URL encoders mangling ids"],"tags":["validation","uuid","bad-request","cakephp"],"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"}