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

@jtbeach

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

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