Visitar URL original
feat: add convenience properties to Notice for before_notify callbacks by stympy · Pull Request #247 · honeybadger-io/honeybadger-python · GitHub
Skip to content

feat: add convenience properties to Notice for before_notify callbacks - #247

Merged
stympy merged 4 commits into
masterfrom
fix-issue-245
Mar 11, 2026
Merged

stympy merged 4 commits into
masterfrom
fix-issue-245

Conversation

@stympy

@stympy stympy commented Mar 5, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes #245: The Notice object passed to before_notify callbacks only exposed a few direct attributes (error_class, error_message, context, tags, fingerprint, request_id). Other useful data was buried inside the nested notice.payload dict, making it hard to discover and use.

Added 11 convenience properties with getters and setters to the Notice class, bringing the Python library in line with the Ruby library's Notice interface:

  • backtrace — error backtrace
  • url — request URL
  • component — request component
  • controller — alias for component (Ruby convention)
  • action — request action
  • params — request parameters
  • cgi_data — CGI/HTTP header variables
  • session — session data
  • local_variables — locals from first backtrace frame
  • causes — exception __cause__ chain
  • id — unique notice UUID (read-only)

All properties support both reading and writing (except id), so before_notify callbacks can inspect and modify the notice payload without navigating the nested dict structure.

Test plan

  • test_before_notify_convenience_properties — verifies all getters return correct defaults
  • test_before_notify_setters — verifies all setters modify the payload correctly
  • All existing before_notify tests pass (5/5)
  • Full core + notice test suites pass (49/49)

🤖 Generated with Claude Code

…s (issue #245)

Expose commonly-needed payload data via Notice properties so that before_notify
callbacks can easily inspect error details without accessing nested dicts.
Added properties: backtrace, message, name, url, component, action, params,
environment. Each property safely defaults to empty string, list, or dict if
the corresponding payload section is missing.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 5, 2026 18:54
Remove message, name, and environment properties since they duplicate
existing attributes (error_message, error_class, config.environment).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Add cgi_data, session, local_variables, causes, id, and controller
(alias for component) to match the Ruby library's Notice interface.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@stympy stympy changed the title Add convenience properties to Notice for before_notify callbacks feat: add convenience properties to Notice for before_notify callbacks Mar 5, 2026
@stympy
stympy requested review from rabidpraxis and subzero10 March 5, 2026 19:43
@subzero10
subzero10 requested a review from Copilot March 6, 2026 07:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread honeybadger/notice.py Resolved
Comment thread honeybadger/notice.py Resolved
Allow before_notify callbacks to modify payload data via property setters
(e.g. notice.url = "..."). Add a note explaining payload caching behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@stympy
stympy requested a review from subzero10 March 6, 2026 20:43
@stympy
stympy merged commit 32bd1c2 into master Mar 11, 2026
41 of 42 checks passed
stympy pushed a commit that referenced this pull request Mar 11, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.2.0](v1.1.3...v1.2.0)
(2026-03-11)


### Features

* add convenience properties to Notice for before_notify callbacks
([#247](#247))
([32bd1c2](32bd1c2))


### Bug Fixes

* ensure celery prefork workers send manual `event()`s regardless of
Insights
([#240](#240))
([0633997](0633997))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

Using AWS Lambda: When trying to filter the event context - everything is empty

3 participants