{"record":{"id":"b6f6e100dd1f305e","repo":"passbolt/passbolt_api","slug":"could-not-save-the-action","errorCode":null,"errorMessage":"Could not save the action.","messagePattern":"Could not save the action\\.","errorType":"exception","errorClass":"InternalErrorException","httpStatus":500,"severity":"error","filePath":"plugins/PassboltCe/Log/src/Model/Table/ActionsTable.php","lineNumber":140,"sourceCode":"        ];\n\n        // Check validation rules.\n        $action = $this->buildEntity($data);\n        if ($action->getErrors()) {\n            throw new ValidationException(__('Could not validate action data.', true), $action, $this);\n        }\n\n        /** @var \\Passbolt\\Log\\Model\\Entity\\Action $actionSaved */\n        $actionSaved = $this->save($action);\n\n        // Check for validation errors.\n        if ($action->getErrors()) {\n            throw new ValidationException(__('Could not validate action data.'), $action, $this);\n        }\n\n        // Check for errors while saving.\n        if (!$actionSaved) {\n            throw new InternalErrorException('Could not save the action.');\n        }\n\n        return $actionSaved;\n    }\n\n    /**\n     * Get cached actions.\n     *\n     * @return \\Cake\\Datasource\\ResultSetInterface\n     */\n    public function getCachedActions(): ResultSetInterface\n    {\n        $actions = $this->find()\n                    ->cache(self::CACHE_KEY)\n                    ->all();\n\n        return $actions;\n    }","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/Log/src/Model/Table/ActionsTable.php#L122-L158","documentation":"ActionsTable::create() throws this InternalErrorException when save() returns false without producing validation errors on the entity. It indicates an infrastructure-level write failure rather than invalid data.","triggerScenarios":"create() called by findOrCreateAction() with valid data, but the INSERT fails: DB connection lost, missing/corrupted actions table, deadlock, or a beforeSave callback returning false without setting errors.","commonSituations":"Migrations not applied after upgrade; database outage or connection-pool exhaustion during heavy logging; disk-full; custom event listeners aborting save silently.","solutions":["Check error.log / DB logs for the real reason save() returned false.","Run pending migrations to align the actions table schema.","Verify DB connectivity, credentials, and disk space on the database host.","Audit plugins for beforeSave/applicationRules returning false without setting entity errors."],"exampleFix":"// before\n$actionSaved = $this->save($action);\nif (!$actionSaved) {\n    throw new InternalErrorException('Could not save the action.');\n}\n// after\n$actionSaved = $this->save($action);\nif (!$actionSaved) {\n    $this->log('Action save failed: ' . json_encode($action->getErrors()), 'error');\n    throw new InternalErrorException('Could not save the action.');\n}","handlingStrategy":"retry","validationCode":"try { $this->getConnection()->query('SELECT 1'); } catch (\\Throwable $e) { // DB unavailable: skip logging path }","typeGuard":"null","tryCatchPattern":"try { $action = $actionsTable->create($data); } catch (InternalErrorException $e) { // transient DB failure: retry once, then log and continue\n    retry: $action = @$actionsTable->create($data) ?? null;\n    if (!$action) { Log::error('Action persistence failed: ' . $e->getMessage()); }\n}","preventionTips":["Run migrations after every upgrade.","Set up DB monitoring for outages, locks, and disk pressure.","Keep save-affecting event listeners on Actions minimal and error-setting.","Isolate audit-log failures from the main request path."],"tags":["database","logging","persistence","cakephp"],"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"}