Skip to content

fix(healthcheck): replace broad exception handler with specific types#451

Closed
bugman-007 wants to merge 1 commit intoLight-Heart-Labs:mainfrom
bugman-007:fix/healthcheck-exception-handling
Closed

fix(healthcheck): replace broad exception handler with specific types#451
bugman-007 wants to merge 1 commit intoLight-Heart-Labs:mainfrom
bugman-007:fix/healthcheck-exception-handling

Conversation

@bugman-007
Copy link
Copy Markdown
Contributor

Summary

  • Replaces except Exception: with specific exception types
  • Complies with CLAUDE.md: "Narrow exceptions at I/O boundaries are fine" but "No broad or silent catches"
  • Makes error handling explicit and debuggable

Changes

  • body.decode() (line 216): except (UnicodeDecodeError, AttributeError) instead of except Exception

Rationale

The original code used a broad except Exception: handler when decoding HTTP response bodies. The decode operation has two specific failure modes:

  1. UnicodeDecodeError - malformed bytes that can't be decoded as UTF-8
  2. AttributeError - body is not bytes (e.g., already a string)

Both map to the same fallback behavior: str(body). Making these explicit improves debuggability.

Test plan

  • Python syntax check passes
  • Manual test: healthcheck handles malformed UTF-8 in response body
  • Manual test: healthcheck handles non-bytes response body

@Lightheartdevs
Copy link
Copy Markdown
Collaborator

Closing as part of v2.1.0 stabilization. We're pausing new feature PRs while we solidify the installer and CI gates. If this is still relevant for v2.2.0 (targeting April 1), please rebase and resubmit. Thank you for contributing.

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.

2 participants