Rebuilding portal_catalog fails with Unable to parse DateTime error

When I try to rebuild my portal_catalog the rebuild fails with the following error:

 SyntaxError("Unable to parse ((DateTime('2020/12/01 11:55:00 UTC'),),), {}",) (Also, the following
 error occurred while attempting to render the standard error message, please see the event log for
 full details: Unable to parse ((DateTime('2020/12/01 11:55:00 UTC'),),), {})

Really looking for suggestions on how to force all DateTime to datetime or how to trace the source of the issue a bit more.

your object property returns ((DateTime('2020/12/01 11:55:00 UTC'),),), {}",) instead of DateTime('2020/12/01 11:55:00 UTC')? Seems like a view casted to a tuple

Okay... I'm doing some debugging to track down the source.
In our site we generate links to other objects. These generated links seem to be the issue:
Not sure why yet, but when I try to edit one of those links I get an error that says:

tuple object has no attribute year

Here's the full traceback

Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module Products.PDBDebugMode.runcall, line 70, in pdb_runcall
  Module ZPublisher.Publish, line 48, in call_object
  Module plone.z3cform.layout, line 63, in __call__
  Module plone.z3cform.layout, line 47, in update
  Module plone.dexterity.browser.edit, line 58, in update
  Module plone.z3cform.fieldsets.extensible, line 65, in update
  Module plone.z3cform.patch, line 30, in GroupForm_update
  Module z3c.form.group, line 141, in update
  Module z3c.form.group, line 52, in update
  Module z3c.form.group, line 48, in updateWidgets
  Module z3c.form.field, line 277, in update
  Module Products.CMFPlone.patches.z3c_form, line 47, in _wrapped
  Module z3c.form.widget, line 132, in update
  Module plone.app.z3cform.converters, line 84, in toWidgetValue
AttributeError: 'tuple' object has no attribute 'year'

Yup... the effective dates are being stored as tuples, these are created using a custom utility which has some code that sets it as a tuple.
Just for the sake of comparison I retrieved the effective date on one of the generated items and it returned:
(DateTime('2021/04/15 20:17:2.949939 UTC'),)

while on a normally created document I get:
DateTime('2021/04/15 20:17:2.949939 UTC')

So yes @yurj your diagnosis was absolutely correct. Finally took some time to do more thorough debugging.

I used Products.PDBDebugMode and the @@pdb view that it provides.

1 Like