Skip to content

Conversation

@alexmojaki
Copy link
Contributor

@alexmojaki alexmojaki commented Jul 31, 2025

Closes #1279

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jul 31, 2025

Deploying logfire-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 25d78cd
Status: ✅  Deploy successful!
Preview URL: https://bfb48297.logfire-docs.pages.dev
Branch Preview URL: https://alex-exc-cycles.logfire-docs.pages.dev

View logs

@alexmojaki alexmojaki requested a review from Copilot July 31, 2025 15:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds handling for cyclic references in exception chains to prevent infinite recursion when canonicalizing exception tracebacks. The implementation tracks previously seen exceptions using their object IDs and displays <repeated exception> for cycles.

  • Adds a seen parameter to track visited exceptions by ID
  • Implements cycle detection before processing exception causes, contexts, and groups
  • Adds comprehensive test coverage for cyclic exception scenarios

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
logfire/_internal/utils.py Implements cycle detection logic in canonicalize_exception_traceback function
tests/test_canonicalize_exception.py Adds test cases for cyclic exception cause and exception group scenarios

@alexmojaki alexmojaki enabled auto-merge (squash) July 31, 2025 15:24
@alexmojaki alexmojaki merged commit 3ae4abb into main Jul 31, 2025
13 checks passed
@alexmojaki alexmojaki deleted the alex/exc-cycles branch July 31, 2025 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Infinite recursion in logfire._internal.utils.canonicalize_exception_traceback when an ExceptionGroup with a self-reference reaches logfire

2 participants