{"record":{"id":"7294253e5d10932a","repo":"passbolt/passbolt_api","slug":"validation-error-message-from-the-failed-entity-save-dynamic","errorCode":null,"errorMessage":"Validation error message from the failed entity save (dynamic)","messagePattern":"Validation error message from the failed entity save \\(dynamic\\)","errorType":"http","errorClass":"ConflictException","httpStatus":409,"severity":"error","filePath":"plugins/PassboltEe/Scim/src/Utility/Resource/UserScimResource.php","lineNumber":793,"sourceCode":"                    $this->Users->patchEntity($this->userEntity, $userPatchData, [\n                        'accessibleFields' => [\n                            'disabled' => true,\n                        ],\n                        'associated' => [\n                            'Profiles' => [\n                                'validate' => 'register',\n                                'accessibleFields' => [\n                                    'first_name' => true,\n                                    'last_name' => true,\n                                ],\n                            ],\n                        ],\n                    ]);\n                    if (!$this->Users->save($this->userEntity, ['atomic' => false])) {\n                        ScimLog::error('Unable to update the user from the request data');\n                        $this->logScimDebug('updateDatabaseUser/user', $userPatchData, $this->userEntity);\n\n                        throw new ConflictException(\n                            $this->getValidationErrorMessage($this->userEntity),\n                            scimType: ScimException::SCIM_TYPE_INVALID_VALUE\n                        );\n                    }\n                }\n                if ($scimEntryPatchData) {\n                    $scimEntry = $this->userEntity->scim_entry ?? null;\n                    if (!$scimEntry) {\n                        $scimEntry = $this->Users->ScimEntries->newEmptyEntity();\n                        $scimEntryPatchData['foreign_model'] = ScimEntry::FOREIGN_MODEL_USERS;\n                        $scimEntryPatchData['foreign_key'] = $this->userEntity->id;\n                    }\n                    $this->Users->ScimEntries->patchEntity($scimEntry, $scimEntryPatchData, [\n                        'accessibleFields' => [\n                            'foreign_key' => true,\n                            'foreign_model' => true,\n                            'external_identifier' => true,\n                            'scim_name' => true,","sourceCodeStart":775,"sourceCodeEnd":811,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/Scim/src/Utility/Resource/UserScimResource.php#L775-L811","documentation":"In updateDatabaseUser(), when Users->save() on the user entity fails (atomic: false), the resource throws a 409 ConflictException whose message is the entity's validation error summary (via getValidationErrorMessage), with scimType `invalidValue`. The message is dynamic — inspect the actual response body to see which field failed.","triggerScenarios":"PATCH/PUT /scim/v2/Users/<id> producing a userPatchData array (profile names, disabled flag) that fails Users table validation rules — e.g. invalid first_name/last_name characters or length, or a conflicting username — during the save call.","commonSituations":"An IdP pushes names with characters or lengths disallowed by passbolt validation; a userName change collides with an existing user or violates the username format rule; locale/encoding issues cause profile fields to fail validation.","solutions":["Read the ConflictException message — it lists the exact field(s) and validation rules that failed.","Fix the attribute value in the IdP source data (length, charset, format) and re-sync.","Run `ddev exec vendor/bin/phpunit` or inspect the Users table validation rules to confirm the constraints before crafting values.","Check logScimDebug output / ScimLog for the submitted $userPatchData and entity errors."],"exampleFix":"// before\n{\"Operations\":[{\"op\":\"replace\",\"path\":\"name.givenName\",\"value\":\"  \"}]}\n// after (non-empty, valid UTF-8, within length limits)\n{\"Operations\":[{\"op\":\"replace\",\"path\":\"name.givenName\",\"value\":\"Alice\"}]}","handlingStrategy":"validation","validationCode":"// pre-validate values against passbolt rules before PATCH\nfunction validName(v) { return typeof v === 'string' && v.trim().length > 0 && v.length <= 255; }\nif (!validName(op.value)) throw new Error('invalid name value for SCIM patch');","typeGuard":"const isNonEmptyString = (v) => typeof v === 'string' && v.trim().length > 0;","tryCatchPattern":"try { await scim.patchUser(id, ops); } catch (e) { if (e.status === 409 && e.scimType === 'invalidValue') { log('validation failed: ' + e.message); } else throw e; }","preventionTips":["Sanitize IdP-sourced names (trim, length, charset) before syncing","Check Users table validation rules for exact constraints","Read the ConflictException body — it names the failing field"],"tags":["scim","validation","conflict","entity-save"],"backgroundTag":"schema-validation-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"}