Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "bugsnag in functional component" in Python

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'bugsnag' in functional components in Python. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

# then we'll report the error
    if r.status_code == 410:
        # Code of 410 means the user has unsubscribed from notifs. This means we
        # must remove the device
        PushDevice.query.\
            filter_by(endpoint=endpoint).\
            delete()

        db.session.commit()
    elif r.status_code // 100 != 2:
        try:
            rejection_response = r.text
        except:
            rejection_response = 'Error reading rejection response'

        if bugsnag.configuration.api_key is not None:
            bugsnag.notify(
                Exception("Web Push dispatch error"),
                meta_data={
                    'webpush_request': {
                        'endpoint': f'{endpoint_url.scheme}://{endpoint_url.netloc}',
                        'status_code': r.status_code
                    },
                    'webpush_response': {
                        'response': rejection_response
                    }
                }
            )

        server.logger.error(f'Notification (Web Push) rejected {notification.uuid} -> {endpoint_url.netloc}:\n{rejection_response}')
def test_flask_intergration_includes_middleware_severity(self):
        app = Flask("bugsnag")

        @app.route("/test")
        def test():
            raise SentinelError("oops")

        handle_exceptions(app)
        app.test_client().get("/test")

        self.assertEqual(1, len(self.server.received))
        payload = self.server.received[0]['json_body']
        event = payload['events'][0]
        self.assertTrue(event['unhandled'])
        self.assertEqual(event['severityReason'], {
            "type": "unhandledExceptionMiddleware",
            "attributes": {
                "framework": "Flask"
            }
def setUp(self):
        super(HandlersTest, self).setUp()
        bugsnag.configure(use_ssl=False,
                          endpoint=self.server.address,
                          api_key='tomatoes',
                          notify_release_stages=['dev'],
                          release_stage='dev',
                          asynchronous=False)
        bugsnag.logger.setLevel(logging.INFO)
def test_notify_configured_api_key(self):
        bugsnag.notify(ScaryException('unexpected failover'))
        headers = self.server.received[0]['headers']
        self.assertEqual('tomatoes', headers['Bugsnag-Api-Key'])
def test_notify_recursive_metadata_array(self):
        a = ['foo', 'bar']
        a.append(a)
        bugsnag.add_metadata_tab('a', {'b': a})
        bugsnag.notify(ScaryException('unexpected failover'))
        json_body = self.server.received[0]['json_body']
        event = json_body['events'][0]
        self.assertEqual(['foo', 'bar', '[RECURSIVE]'],
                         event['metaData']['a']['b'])
def test_notify_override_metadata_sections(self):
        bugsnag.add_metadata_tab('food', {'beans': 3, 'corn': 'purple'})
        bugsnag.notify(ScaryException('unexpected failover'),
                       meta_data={'food': {'beans': 5},
                                  'skills': {'spear': 6}})
        json_body = self.server.received[0]['json_body']
        event = json_body['events'][0]
        self.assertEqual(6, event['metaData']['skills']['spear'])
        self.assertEqual('purple', event['metaData']['food']['corn'])
        self.assertEqual(5, event['metaData']['food']['beans'])
def test_notify_device_filter(self):
        bugsnag.configure(params_filters=['hostname'])
        bugsnag.notify(ScaryException('unexpected failover'))
        json_body = self.server.received[0]['json_body']
        event = json_body['events'][0]
        self.assertEqual('[FILTERED]', event['device']['hostname'])
def test_notify_recursive_metadata_dict(self):
        a = {'foo': 'bar'}
        a['baz'] = a
        bugsnag.add_metadata_tab('a', a)
        bugsnag.notify(ScaryException('unexpected failover'))
        json_body = self.server.received[0]['json_body']
        event = json_body['events'][0]
        self.assertEqual('bar', event['metaData']['a']['foo'])
        self.assertEqual('[RECURSIVE]', event['metaData']['a']['baz']['baz'])
def test_middleware_stack_order_legacy(self):
        def first_callback(notification):
            notification.meta_data['test']['array'].append(1)

        def second_callback(notification):
            notification.meta_data['test']['array'].append(2)

        # Add a regular callback function
        bugsnag.before_notify(second_callback)

        # Simulate an internal middleware
        bugsnag.legacy.configuration.internal_middleware.before_notify(
                first_callback)

        bugsnag.notify(ScaryException('unexpected failover'),
                       test={'array': []})
        json_body = self.server.received[0]['json_body']
        event = json_body['events'][0]

        self.assertEqual(event['metaData']['test']['array'], [1, 2])
def test_notify_override_user(self):
        bugsnag.notify(ScaryException('unexpected failover'),
                       user={'name': 'bob',
                             'email': 'mcbob@example.com',
                             'id': '542347329'})
        json_body = self.server.received[0]['json_body']
        event = json_body['events'][0]
        self.assertEqual('bob', event['user']['name'])
        self.assertEqual('542347329', event['user']['id'])
        self.assertEqual('mcbob@example.com', event['user']['email'])

Is your System Free of Underlying Vulnerabilities?
Find Out Now