passbolt/passbolt_api · error · InternalErrorException
Could not save the secret access.
Error message
Could not save the secret access.
What it means
Thrown by SecretAccessesTable::createFromSecretDetails() when save() returns false after validation succeeded — meaning the INSERT into secret_accesses failed at the persistence layer (constraint, lock, connection, or an event listener returning false).
Solutions
- Confirm the secret_id and user_id exist in secrets/users tables at save time
- Run passbolt migrate to ensure the secret_accesses table schema is current
- Inspect database/error logs for the underlying SQL error and fix the constraint
- Retry the operation if the failure was transient (lock timeout, dead connection)
Example fix
// before
$this->SecretAccesses->createFromSecretDetails($userId, $secretId, $secret, $created); // may 500
// after
$secretExists = $this->Secrets->exists(['id' => $secretId]);
if (!$secretExists) {
throw new BadRequestException(__('The secret does not exist.'));
}
$this->SecretAccesses->createFromSecretDetails($userId, $secretId, $secret, $created); Defensive patterns
Strategy: try-catch
Validate before calling
$secretExists = $this->Secrets->exists(['id' => $secretId]);
$userExists = $this->Users->exists(['id' => $userId]);
if (!$secretExists || !$userExists) { throw new BadRequestException(...); } Type guard
if (!($secret instanceof \App\Model\Entity\Secret && $secret->id)) { throw new \InvalidArgumentException('Persisted secret required'); } Try / catch
try {
$this->SecretAccesses->createFromSecretEntity($user, $secret);
} catch (\Cake\Http\Exception\InternalErrorException $e) {
$this->log('Secret access save failed: ' . $e->getMessage());
// check DB logs, migrate if schema drift, retry once if transient
} Prevention
- Keep schema current with passbolt migrate
- Verify referenced secret/user rows exist before logging
- Monitor DB error logs for secret_accesses constraint failures
- Avoid hard-deleting secrets while audit logging is in flight
When it happens
Trigger: $this->save($secretAccess) returning falsy: database constraint violation on secret_accesses (bad secret_id/user_id foreign keys), table missing after skipped migration, transaction rollback, or a Model.event listener aborting the save.
Common situations: Secret deleted concurrently by another request, missing secret_accesses table (migration not run), database disk-full/replication issues, and schema mismatch after partial plugin upgrades.
Related errors
- Could not save permission history.
- Could not save the secret history.
- Could not save the action.
- Could not save the action log.
- Could not save the comment, please try again later.
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/ec09ad49fda5e650.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/PassboltCe/Log/src/Model/Table/SecretAccessesTable.php:177
'secret_id' => $secretId,
];
// Check validation rules.
$secretAccess = $this->buildEntity($data);
if ($secretAccess->getErrors()) {
throw new ValidationException(__('Could not validate secret access data.', true), $secretAccess, $this);
}
$secretAccessSaved = $this->save($secretAccess);
// Check for validation errors. (associated models too).
if ($secretAccess->getErrors()) {
throw new ValidationException(__('Could not validate secret access data.'), $secretAccess, $this);
}
// Check for errors while saving.
if (!$secretAccessSaved) {
throw new InternalErrorException('Could not save the secret access.');
}
return $secretAccessSaved;
}
}
View on GitHub (pinned to 31c1bbc10f)