Skip to content

Commit

Permalink
Issue 5966 - CLI - Custom schema object is removed on a failed edit (#…
Browse files Browse the repository at this point in the history
…5967)

Description: When the failure happens during a custom schema edit operation
in both CLI and UI (because it uses the CLI command), we first remove
the old schema object, and only then do we add the new one (edited).

Bring the old schema object on the failed attempt.

Resolves: #5966

Reviewed by: @mreynolds389 (Thanks!)
  • Loading branch information
droideck committed Oct 24, 2023
1 parent 3e51635 commit 4285cee
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib389/lib389/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,11 @@ def _edit_schema_object(self, name, parameters, object_model):
raise ValueError('Schema is already in the required state. Nothing to change')

self.remove(attr_name, schema_object_str_old)
return self.add(attr_name, schema_object_str)
try:
return self.add(attr_name, schema_object_str)
except ldap.LDAPError:
self.add(attr_name, schema_object_str_old)
raise

def reload(self, schema_dir=None):
"""Reload the schema"""
Expand Down

0 comments on commit 4285cee

Please sign in to comment.