passbolt/passbolt_api · error · InternalErrorException

Could not log secret access entry.

Error message

Could not log secret access entry.

What it means

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.

Solutions

  1. Inspect the chained exception (previous) in server logs for the root database error.
  2. Run migrations to ensure the secret_accesses table exists and is current (ddev refresh).
  3. Verify database connectivity and that the passbolt/log plugin is enabled.
  4. Retry the request once the database issue is resolved — secrets may need re-fetching since the response was aborted.

Example fix

// before
try {
  $SecretAccesses->createFromSecretDetails($uac, $resourceId, $secretId);
} catch (Exception $e) {
  throw new InternalErrorException('Could not log secret access entry.', 500, $e);
}
// after (admin-side fix, not code): ensure table exists
// bin/cake migrations migrate --plugin Passbolt/Log
Defensive patterns

Strategy: try-catch

Try / catch

try { const res = await api.get('/resources.json?contain[secret]=1'); } catch (e) { if (e.status === 500) { adminCheckLogPluginMigrations(); } throw e; }

Prevention

When it happens

Trigger: 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.

Common situations: Missing or outdated passbolt log plugin migrations (secret_accesses table absent), database outage/lock, custom plugins interfering, secret data shape changed by another plugin.

Related errors


AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17). Data as JSON: /api/errors/2f8e7be7a45bb231. Report an issue: GitHub.

Appendix: source

Thrown at src/Controller/Resources/ResourcesIndexController.php:139

        if (!$this->Resources->getAssociation('Secrets')->hasAssociation('SecretAccesses')) {
            return;
        }

        foreach ($resources as $resource) {
            $secrets = Hash::get($resource, 'secrets');
            if (!isset($secrets)) {
                continue;
            }

            foreach ($secrets as $secret) {
                try {
                    $this->Resources->Secrets->SecretAccesses->createFromSecretDetails(
                        $this->User->getAccessControl(),
                        Hash::get($secret, 'resource_id'),
                        Hash::get($secret, 'id'),
                    );
                } catch (Exception $e) {
                    throw new InternalErrorException('Could not log secret access entry.', 500, $e);
                }
            }
        }
    }
}

View on GitHub (pinned to 31c1bbc10f)