{"record":{"id":"2f8e7be7a45bb231","repo":"passbolt/passbolt_api","slug":"could-not-log-secret-access-entry-resourcesindexcontroller","errorCode":null,"errorMessage":"Could not log secret access entry.","messagePattern":"Could not log secret access entry\\.","errorType":"exception","errorClass":"InternalErrorException","httpStatus":500,"severity":"error","filePath":"src/Controller/Resources/ResourcesIndexController.php","lineNumber":139,"sourceCode":"        if (!$this->Resources->getAssociation('Secrets')->hasAssociation('SecretAccesses')) {\n            return;\n        }\n\n        foreach ($resources as $resource) {\n            $secrets = Hash::get($resource, 'secrets');\n            if (!isset($secrets)) {\n                continue;\n            }\n\n            foreach ($secrets as $secret) {\n                try {\n                    $this->Resources->Secrets->SecretAccesses->createFromSecretDetails(\n                        $this->User->getAccessControl(),\n                        Hash::get($secret, 'resource_id'),\n                        Hash::get($secret, 'id'),\n                    );\n                } catch (Exception $e) {\n                    throw new InternalErrorException('Could not log secret access entry.', 500, $e);\n                }\n            }\n        }\n    }\n}\n","sourceCodeStart":121,"sourceCodeEnd":145,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Controller/Resources/ResourcesIndexController.php#L121-L145","documentation":"A 500 thrown by ResourcesIndexController::_logSecretAccesses when SecretAccessesTable::createFromSecretDetails() throws while trying to persist an audit-log entry recording that the user accessed a secret. The original exception is chained as the third argument. The secrets themselves were already retrieved; only the audit logging failed.","triggerScenarios":"GET /resources.json with contain[]=secrets (secret retrieval) when the SecretAccesses table write fails — e.g. the passbolt/log plugin tables are missing, the database is down, or createFromSecretDetails throws on invalid resource/secret IDs.","commonSituations":"Missing or outdated passbolt log plugin migrations (secret_accesses table absent), database outage/lock, custom plugins interfering, secret data shape changed by another plugin.","solutions":["Inspect the chained exception (previous) in server logs for the root database error.","Run migrations to ensure the secret_accesses table exists and is current (ddev refresh).","Verify database connectivity and that the passbolt/log plugin is enabled.","Retry the request once the database issue is resolved — secrets may need re-fetching since the response was aborted."],"exampleFix":"// before\ntry {\n  $SecretAccesses->createFromSecretDetails($uac, $resourceId, $secretId);\n} catch (Exception $e) {\n  throw new InternalErrorException('Could not log secret access entry.', 500, $e);\n}\n// after (admin-side fix, not code): ensure table exists\n// bin/cake migrations migrate --plugin Passbolt/Log","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { const res = await api.get('/resources.json?contain[secret]=1'); } catch (e) { if (e.status === 500) { adminCheckLogPluginMigrations(); } throw e; }","preventionTips":["Run passbolt log plugin migrations after every install/upgrade","Monitor database health (connectivity, locks, disk space)","Alert on 500s from secret endpoints — they indicate audit-log schema drift"],"tags":["http-500","audit-log","secrets","database"],"backgroundTag":"database-write-failed","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"}