Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Flask middleware raises AttributeError for 404 routes #777

Closed

Description

@jtbeach

Describe your environment.
Python 3.7, Flask 1.1, OpenCensus 0.7.3

Steps to reproduce.

  1. Run opencensus with the Flask middleware enabled with any Flask app
  2. Hit a URL that does not map to a rule (ie. /foo)

What is the expected behavior?
Don't expect exceptions thrown for 404 routes

What is the actual behavior?
Every 404 route is generating exceptions

Additional context.

The problem is caused by the following PR: #759

It assumes that the url_rule is not None -- if you hit any non-existent URL (ie. a 404-triggering URL), then request.url_rule will be None and code will raise an AttributeError

Activity

  1. reyang commented on Aug 30, 2019

    @reyang
    Contributor

    @olance would you help on this? Thanks!

  2. jtbeach commented on Sep 2, 2019

    @jtbeach
    ContributorAuthor

    PR raised in #781

  3. olance commented on Sep 2, 2019

    @olance
    Contributor

    @reyang Sorry for the lag, and thanks @jtbeach for chiming in!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions