FossilRepo
Add exception logging to ticket_detail for debugging 500
Commit
f842575b9f3ec4fca1f644bc48653d2852adc0eae74754493b2d745233a54264
Parent
c9d9fe5731c152e…
1 file changed
+11
-1
+11
-1
| --- fossil/views.py | ||
| +++ fossil/views.py | ||
| @@ -768,25 +768,35 @@ | ||
| 768 | 768 | }, |
| 769 | 769 | ) |
| 770 | 770 | |
| 771 | 771 | |
| 772 | 772 | def ticket_detail(request, slug, ticket_uuid): |
| 773 | + import logging | |
| 774 | + | |
| 775 | + logger = logging.getLogger("fossil.views") | |
| 776 | + | |
| 773 | 777 | project, fossil_repo, reader = _get_repo_and_reader(slug, request) |
| 774 | 778 | |
| 775 | 779 | with reader: |
| 776 | 780 | ticket = reader.get_ticket_detail(ticket_uuid) |
| 777 | 781 | comments = reader.get_ticket_comments(ticket_uuid) if ticket else [] |
| 778 | 782 | |
| 779 | 783 | if not ticket: |
| 780 | 784 | raise Http404("Ticket not found") |
| 781 | 785 | |
| 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 | + | |
| 783 | 792 | rendered_comments = [] |
| 784 | 793 | for c in comments: |
| 785 | 794 | try: |
| 786 | 795 | comment_html = mark_safe(sanitize_html(_render_fossil_content(c["comment"], project_slug=slug))) |
| 787 | 796 | except Exception: |
| 797 | + logger.exception("ticket_detail: failed to render comment for %s", ticket_uuid) | |
| 788 | 798 | comment_html = mark_safe(f"<pre>{c['comment']}</pre>") |
| 789 | 799 | rendered_comments.append( |
| 790 | 800 | { |
| 791 | 801 | "user": c["user"], |
| 792 | 802 | "timestamp": c["timestamp"], |
| 793 | 803 |
| --- 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 |