Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ Changelog

2.9.17 (2026-04-10)
-------------------
Bug fixes:

-- Fix decisionDate filter: ensure getDecisionDate indexer always
returns a DateTime (including PloneMeeting data).
[WBoudabous] (SUP-52501)


Bug fixes:

Expand Down
5 changes: 3 additions & 2 deletions src/Products/urban/indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,9 @@ def genericlicence_decisiondate(licence):
)
return decision_date
if linked_pm_items:
if "date" in linked_pm_items[0]["extra_include_meeting"].keys():
return linked_pm_items[0]["extra_include_meeting"]["date"]
date_str = linked_pm_items[0]["extra_include_meeting"].get("date")
if date_str:
return DateTime(date_str)
return decision_event.getDecisionDate() or decision_event.getEventDate()
Comment on lines +277 to 280

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

getDecisionDate is still not guaranteed to return DateTime in all paths.

The new PloneMeeting path is improved, but the fallback at Line [263]-Line [275] still returns datetime.date, which violates the PR objective and can conflict with DateIndex. Also, linked_pm_items[0]["extra_include_meeting"] is still not safely guarded.

Proposed fix
@@
-            if brain and brain[0].getDecisionDate:
-                old_decision_date = brain[0].getDecisionDate
-                if type(old_decision_date) is DateTime:
-                    decision_date = date(
-                        old_decision_date.year(),
-                        old_decision_date.month(),
-                        old_decision_date.day(),
-                    )
-                else:
-                    decision_date = date(
-                        old_decision_date.year,
-                        old_decision_date.month,
-                        old_decision_date.day,
-                    )
-                return decision_date
+            if brain and brain[0].getDecisionDate:
+                old_decision_date = brain[0].getDecisionDate
+                if isinstance(old_decision_date, DateTime):
+                    return old_decision_date
+                return DateTime(old_decision_date.isoformat())
         if linked_pm_items:
-            date_str = linked_pm_items[0]["extra_include_meeting"].get("date")
+            meeting = linked_pm_items[0].get("extra_include_meeting") or {}
+            date_str = meeting.get("date")
             if date_str:
                 return DateTime(date_str)
-        return decision_event.getDecisionDate() or decision_event.getEventDate()
+        decision_date = decision_event.getDecisionDate() or decision_event.getEventDate()
+        if decision_date and not isinstance(decision_date, DateTime):
+            decision_date = DateTime(decision_date.isoformat())
+        return decision_date
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Products/urban/indexes.py` around lines 277 - 280, The fallback path
still returns a plain datetime.date and doesn't safely access the PloneMeeting
data; update the logic in the function that builds the index value (the block
referencing linked_pm_items and calling
decision_event.getDecisionDate()/getEventDate()) to: 1) guard access to
linked_pm_items[0]["extra_include_meeting"] by using
.get("extra_include_meeting") and then .get("date") to avoid
KeyError/AttributeError; 2) when a date string is present create and return a
DateTime(date_str); and 3) for the existing fallbacks call
decision_event.getDecisionDate() and decision_event.getEventDate() and, if they
are a datetime.date or datetime.datetime, convert them to a DateTime instance
before returning (use the DateTime constructor), so the function always returns
a DateTime. Ensure DateTime is imported where used.



Expand Down