{"record":{"id":"5577629cc816afc2","repo":"passbolt/passbolt_api","slug":"the-s-resource-with-id-s-was-not-found","errorCode":null,"errorMessage":"The %s resource with id `%s` was not found","messagePattern":"The (.+?) resource with id `(.+?)` was not found","errorType":"exception","errorClass":"Passbolt\\Scim\\Exception\\ResourceNotFoundException","httpStatus":404,"severity":"error","filePath":"plugins/PassboltEe/Scim/src/Utility/Resource/UserScimResource.php","lineNumber":233,"sourceCode":"        }\n    }\n\n    /**\n     * @inheritDoc\n     */\n    public function setFromDatabase(string $internalId): self\n    {\n        if (!Validation::uuid($internalId)) {\n            throw new BadRequestException(__('The user identifier should be a valid UUID.'));\n        }\n        /** @var \\App\\Model\\Entity\\User|null $userEntity */\n        $userEntity = $this->Users\n            ->findForScim([$this->Users->aliasField('id') => $internalId], findDeleted: true)\n            ->contain(['Profiles', 'ScimEntries'])\n            ->first();\n        $this->userEntity = $userEntity;\n        if (!$this->userEntity) {\n            throw new ResourceNotFoundException(\n                sprintf('The %s resource with id `%s` was not found', $this->getType(), $internalId)\n            );\n        }\n        if ($this->userEntity->deleted) {\n            throw new ResourceNotFoundException(\n                sprintf('The %s resource with id `%s` is already deleted', $this->getType(), $internalId)\n            );\n        }\n\n        $this->id = $this->userEntity->id;\n        $this->externalId = $this->userEntity->scim_entry?->external_identifier;\n        $this->userName = $this->userEntity->scim_entry?->scim_name;\n        $this->email = $this->userEntity->username;\n        $this->firstName = $this->userEntity->profile?->first_name;\n        $this->lastName = $this->userEntity->profile?->last_name;\n        $this->active = !$this->userEntity->disabled;\n\n        return $this;","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/Scim/src/Utility/Resource/UserScimResource.php#L215-L251","documentation":"After validating the UUID, setFromDatabase() looks up the user via Users->findForScim() (including deleted users) and, if no entity matches, throws ResourceNotFoundException with the SCIM resource type and the id that was requested. This mirrors SCIM's 404 semantics for GET/PUT/PATCH on nonexistent resources.","triggerScenarios":"Calling setFromDatabase($id) where $id is a well-formed UUID that does not exist in the users table — e.g. PATCH/PUT /scim/v2/Users/{uuid} for a user already permanently removed or an id from another environment.","commonSituations":"Stale IdP directory referencing a user deleted on the passbolt side; ID from staging used in production; hard-delete vs soft-delete migrations cleaned the row; typos in stored mapping tables.","solutions":["Verify the UUID exists: check the users table (SELECT id FROM users WHERE id = '...').","If the user was legitimately deleted, have the IdP deprovision/remove its mapping instead of patching.","Re-sync the IdP directory with current passbolt users to fix stale identifiers.","If IDs came from another environment, use the correct environment's identifiers."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check existence before PATCH/PUT\n$user = $usersTable->find()->where(['id' => $uuid, 'deleted' => false])->first();\nif (!$user) {\n    throw new RuntimeException(\"User $uuid not found; skipping SCIM operation\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    $resource->setFromDatabase($uuid);\n} catch (ResourceNotFoundException $e) {\n    // treat as 404: mark the IdP mapping as stale, skip or deprovision\n}","preventionTips":["Re-sync IdP user lists with passbolt regularly to drop stale ids.","Never reuse ids across environments.","Handle 404 from SCIM endpoints as deprovision-complete, not retryable.","Log the id and resource type from the exception message."],"tags":["scim","not-found","user"],"backgroundTag":"resource-not-found","analyzedSha":"31c1bbc10f32808a607fa9bd81891e898779c0bc","analyzedAt":"2026-09-17T00:04:38.960Z","contentChangedAt":"2026-09-17T00:04:38.960Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}