misc: add proper truncation to logged error ids (#23329)

This commit is contained in:
Frédéric Péters 2018-04-23 19:12:58 +02:00
parent f8d9977b2f
commit 0d0d357a70
2 changed files with 11 additions and 1 deletions

View File

@ -3783,6 +3783,16 @@ def test_backoffice_logged_errors(pub):
resp = resp2.click('ZeroDivisionError')
assert 'href="http://example.net/backoffice/management/test/' in resp.body
# very long error string (check it creates a viable tech_id)
jump.condition = {'type': 'python', 'value': 'x'*500} # NameError + very long string
workflow.store()
app = get_app(pub)
resp = app.get('/test/')
resp = resp.form.submit('submit').follow()
resp = resp.form.submit('submit')
assert LoggedError.count() == 2
# remove formdef
FormDef.wipe()
resp = resp2.click('ZeroDivisionError')

View File

@ -82,7 +82,7 @@ class LoggedError(XmlStorableObject):
@property
def tech_id(self):
return '%s-%s-%s' % (self.formdef_id, self.workflow_id, simplify(self.summary))[:200]
return ('%s-%s-%s' % (self.formdef_id, self.workflow_id, simplify(self.summary)))[:200]
def get_formdef(self):
return FormDef.get(self.formdef_id, ignore_errors=True)