{"record":{"id":"af58ec076029e01f","repo":"passbolt/passbolt_api","slug":"the-user-does-not-exist-usersviewcontroller","errorCode":null,"errorMessage":"The user does not exist.","messagePattern":"The user does not exist\\.","errorType":"exception","errorClass":"Cake\\Http\\Exception\\NotFoundException","httpStatus":404,"severity":"error","filePath":"src/Controller/Users/UsersViewController.php","lineNumber":79,"sourceCode":"\n        // Trigger an event to filter data, decorate results, add contain, etc.\n        $event = TableFindIndexBefore::create(\n            $query,\n            FindIndexOptions::createFromArray(['query' => $query]),\n            $usersTable\n        );\n        /** @var \\App\\Model\\Event\\TableFindIndexBefore $event */\n        $this->getEventManager()->dispatch($event);\n        $query = $event->getQuery();\n\n        if ($this->isFeaturePluginEnabled('MultiFactorAuthentication')) {\n            (new IsMfaEnabledQueryService())->decorateForView($query, $this->User->getAccessControl(), $id);\n        }\n\n        try {\n            $user = $query->first();\n        } catch (Exception $exception) {\n            throw new NotFoundException(__('The user does not exist.'));\n        }\n        if (empty($user)) {\n            throw new NotFoundException(__('The user does not exist.'));\n        }\n\n        $this->success(__('The operation was successful.'), $user);\n    }\n}\n","sourceCodeStart":61,"sourceCodeEnd":88,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Controller/Users/UsersViewController.php#L61-L88","documentation":"After building the user query (including MFA decoration), the controller wraps `$query->first()` in a try/catch: any exception from the database layer (e.g. malformed UUID reaching the query, SQL error from the MFA decoration query) is swallowed and re-thrown as a 404 NotFoundException 'The user does not exist.' to avoid leaking storage errors.","triggerScenarios":"GET /users/{id}.json where executing the decorated query throws — most commonly when the MFA decoration query (IsMfaEnabledQueryService::decorateForView) fails, or the id passed to the query is malformed/unusable by the driver.","commonSituations":"MFA plugin tables missing/mis-migrated so the decoration query errors; database connectivity issues; a non-UUID id slipping through to the query layer; DB driver differences (Postgres vs MySQL) causing the MFA subquery to fail.","solutions":["Run migrations for the MFA plugin (`passbolt migrate` / `bin/cake passbolt migrate`) so IsMfaEnabledQueryService finds its tables.","Check database connectivity and server logs (logs/error.log) for the underlying exception the 404 masks.","Confirm the requested id is a valid, existing user UUID.","If the user genuinely does not exist, this is expected — list users via GET /users.json to get valid ids."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const res = await api.get(`/users/${uuid}.json`);\n} catch (e) {\n  if (e.response?.status === 404) {\n    // Masked query failure (MFA decoration/DB issue) or missing user:\n    // check server logs and run migrations before assuming the user is absent.\n    console.warn('User lookup failed; verify user exists and MFA migrations are applied.');\n    return null;\n  }\n  throw e;\n}","preventionTips":["Keep MFA plugin migrations current (`passbolt migrate`) so the decoration query never fails.","Treat 404 from this endpoint as ambiguous: check server logs for the underlying exception.","Confirm DB connectivity before diagnosing 'missing user' errors.","Test lookups across drivers (Postgres/MySQL) when upgrading."],"tags":["passbolt","cakephp","not-found","user","http-404"],"backgroundTag":"user-not-found","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"}