From 7ec38b87f8df7d0419d659cd4a6c5e2a2f9a6d01 Mon Sep 17 00:00:00 2001 From: giles Date: Thu, 19 Feb 2026 19:29:07 +0000 Subject: [PATCH] Add widget debug logging to post context processor Co-Authored-By: Claude Opus 4.6 --- bp/post/routes.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/bp/post/routes.py b/bp/post/routes.py index 6fcf877..732a2a9 100644 --- a/bp/post/routes.py +++ b/bp/post/routes.py @@ -69,16 +69,25 @@ def register(): db_post_id = (g.post_data.get("post") or {}).get("id") post_slug = (g.post_data.get("post") or {}).get("slug", "") - # Widget-driven container nav — only include widgets with data + # Widget-driven container nav + import logging + _log = logging.getLogger("coop") + _log.warning("WIDGET DEBUG: %d nav widgets registered, post_id=%s slug=%s", + len(widgets.container_nav), db_post_id, post_slug) container_nav_loaded = [] for w in widgets.container_nav: - wctx = await w.context_fn( - g.s, container_type="page", container_id=db_post_id, - post_slug=post_slug, - ) - # Include widget if it has any list data - if any(v for v in wctx.values() if isinstance(v, list) and v): - container_nav_loaded.append({"widget": w, "ctx": wctx}) + try: + wctx = await w.context_fn( + g.s, container_type="page", container_id=db_post_id, + post_slug=post_slug, + ) + has_data = any(v for v in wctx.values() if isinstance(v, list) and v) + _log.warning("WIDGET DEBUG: %s has_data=%s keys=%s", w.domain, has_data, + {k: len(v) if isinstance(v, list) else v for k, v in wctx.items()}) + if has_data: + container_nav_loaded.append({"widget": w, "ctx": wctx}) + except Exception as e: + _log.exception("WIDGET ERROR: %s: %s", w.domain, e) ctx = { **p_data,