Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #387: recursive error logging for non-http events #390

Merged
merged 4 commits into from
Sep 21, 2021

Conversation

bxsx
Copy link
Contributor

@bxsx bxsx commented Sep 19, 2021

Description of the change

This PR addresses an issue reported in #387.

In the current release, the SDK logs an error if a request object does not exist in the local context. This behavior leads to recursive error logging when RollbarHandler is used. The RollbarHandler tries to add the request object to the payload itself, so in the absence of a request in the local context, it again tries to log the error by using RollbarHandler and invokes rollbar.get_request() that again causes the same error.

The provided solution removes logging errors in case of missing a request in the local context. Instead, it returns None.
Additionally, the PR restricts the storage of request objects only for the ASGI-HTTP scope, so for other scopes, it blindly stores None without trying to create the request object itself.

I merged the PR #389 branch to pass CI tests. This PR should be merged after approval of #389.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Related issues

Checklists

Development

  • Lint rules pass locally
  • The code changed/added as part of this pull request has been covered with tests
  • All tests related to the changed code pass in development

Code review

  • This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached
  • "Ready for review" label attached to the PR and reviewers mentioned in a comment
  • Changes have been reviewed by at least one other engineer
  • Issue from task tracker has a link to this pull request

The currently used version of `setuptools` has a bug,
so the version requirements are not properly respected.
In the current version, `requests>= 0.12.1` always installs
the latest version of the package.
@shortcut-integration
Copy link

@bxsx bxsx merged commit 166b601 into master Sep 21, 2021
@bxsx bxsx deleted the bxsx/fix-starlette-log-error branch September 21, 2021 10:38
@bxsx bxsx added this to the v0.16.2 milestone Jan 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Circular error logging for non-http events in Starlette app
2 participants