FossilRepo

Add exception logging to ticket_detail for debugging 500

ragelink 2026-04-08 13:59 trunk
Commit f842575b9f3ec4fca1f644bc48653d2852adc0eae74754493b2d745233a54264
1 file changed +11 -1
+11 -1
--- fossil/views.py
+++ fossil/views.py
@@ -768,25 +768,35 @@
768768
},
769769
)
770770
771771
772772
def ticket_detail(request, slug, ticket_uuid):
773
+ import logging
774
+
775
+ logger = logging.getLogger("fossil.views")
776
+
773777
project, fossil_repo, reader = _get_repo_and_reader(slug, request)
774778
775779
with reader:
776780
ticket = reader.get_ticket_detail(ticket_uuid)
777781
comments = reader.get_ticket_comments(ticket_uuid) if ticket else []
778782
779783
if not ticket:
780784
raise Http404("Ticket not found")
781785
782
- body_html = mark_safe(sanitize_html(_render_fossil_content(ticket.body, project_slug=slug))) if ticket.body else ""
786
+ try:
787
+ body_html = mark_safe(sanitize_html(_render_fossil_content(ticket.body, project_slug=slug))) if ticket.body else ""
788
+ except Exception:
789
+ logger.exception("ticket_detail: failed to render body for %s", ticket_uuid)
790
+ body_html = mark_safe(f"<pre>{ticket.body}</pre>") if ticket.body else ""
791
+
783792
rendered_comments = []
784793
for c in comments:
785794
try:
786795
comment_html = mark_safe(sanitize_html(_render_fossil_content(c["comment"], project_slug=slug)))
787796
except Exception:
797
+ logger.exception("ticket_detail: failed to render comment for %s", ticket_uuid)
788798
comment_html = mark_safe(f"<pre>{c['comment']}</pre>")
789799
rendered_comments.append(
790800
{
791801
"user": c["user"],
792802
"timestamp": c["timestamp"],
793803
--- fossil/views.py
+++ fossil/views.py
@@ -768,25 +768,35 @@
768 },
769 )
770
771
772 def ticket_detail(request, slug, ticket_uuid):
 
 
 
 
773 project, fossil_repo, reader = _get_repo_and_reader(slug, request)
774
775 with reader:
776 ticket = reader.get_ticket_detail(ticket_uuid)
777 comments = reader.get_ticket_comments(ticket_uuid) if ticket else []
778
779 if not ticket:
780 raise Http404("Ticket not found")
781
782 body_html = mark_safe(sanitize_html(_render_fossil_content(ticket.body, project_slug=slug))) if ticket.body else ""
 
 
 
 
 
783 rendered_comments = []
784 for c in comments:
785 try:
786 comment_html = mark_safe(sanitize_html(_render_fossil_content(c["comment"], project_slug=slug)))
787 except Exception:
 
788 comment_html = mark_safe(f"<pre>{c['comment']}</pre>")
789 rendered_comments.append(
790 {
791 "user": c["user"],
792 "timestamp": c["timestamp"],
793
--- fossil/views.py
+++ fossil/views.py
@@ -768,25 +768,35 @@
768 },
769 )
770
771
772 def ticket_detail(request, slug, ticket_uuid):
773 import logging
774
775 logger = logging.getLogger("fossil.views")
776
777 project, fossil_repo, reader = _get_repo_and_reader(slug, request)
778
779 with reader:
780 ticket = reader.get_ticket_detail(ticket_uuid)
781 comments = reader.get_ticket_comments(ticket_uuid) if ticket else []
782
783 if not ticket:
784 raise Http404("Ticket not found")
785
786 try:
787 body_html = mark_safe(sanitize_html(_render_fossil_content(ticket.body, project_slug=slug))) if ticket.body else ""
788 except Exception:
789 logger.exception("ticket_detail: failed to render body for %s", ticket_uuid)
790 body_html = mark_safe(f"<pre>{ticket.body}</pre>") if ticket.body else ""
791
792 rendered_comments = []
793 for c in comments:
794 try:
795 comment_html = mark_safe(sanitize_html(_render_fossil_content(c["comment"], project_slug=slug)))
796 except Exception:
797 logger.exception("ticket_detail: failed to render comment for %s", ticket_uuid)
798 comment_html = mark_safe(f"<pre>{c['comment']}</pre>")
799 rendered_comments.append(
800 {
801 "user": c["user"],
802 "timestamp": c["timestamp"],
803

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button