Skip to content

Commit

Permalink
fix handling of subscription validation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
UlrichB22 committed Feb 29, 2024
1 parent 5e6f856 commit d37d300
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/moin/apps/frontend/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
from moin.signalling import item_displayed, item_modified
from moin.storage.middleware.protecting import AccessDenied, gen_fqnames
from moin.converters import default_registry as reg
# from moin.cli.migration.moin19.import19 import hash_hexdigest
from moin.storage.middleware.validation import validate_data
import moin.utils.mimetype as mime_type

Expand Down Expand Up @@ -2397,7 +2396,11 @@ class UserSettingsUIForm(Form):
'verification email failed. Please try again later.'),
"error"))
else:
flaskg.user.save()
try:
flaskg.user.save()
except ValueError as err:
response['flash'].append((str(err), 'error'))

else:
# validation failed
response['flash'].append((_("Nothing saved."), "error"))
Expand Down
9 changes: 7 additions & 2 deletions src/moin/storage/middleware/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1221,9 +1221,14 @@ def store_revision(self, meta, data, overwrite=False,
logging.warning("data validation skipped because metadata is invalid, see below")
val = []
for e in m.children:
logging.warning("{0}, {1}, {2}".format(e.valid, e.name, e.raw))
if e.valid is False:
if e.name == 'subscriptions':
for sub in e.children:
if sub.valid is False:
val.append('"{}". {}'.format(str(sub), str(sub.errors[0])))
e.valid = False
elif e.valid is False:
val.append(str(e))
logging.warning("{0}, {1}, {2}".format(e.valid, e.name, e.raw))
if VALIDATION_HANDLING == VALIDATION_HANDLING_STRICT:
raise ValueError(_('Error: metadata validation failed, invalid field value(s) = {0}'.format(
', '.join(val)
Expand Down

0 comments on commit d37d300

Please sign in to comment.