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

ProfilerMiddleware's default filename_format causes ValueError when ProfilerMiddleware is used with profile_dir #1511

jlove-bazaarvoice opened this issue Apr 10, 2019 · 2 comments


Copy link

jlove-bazaarvoice commented Apr 10, 2019


$ sw_vers 
ProductName:	Mac OS X
ProductVersion:	10.13.6
BuildVersion:	17G3025

$ python --version
Python 3.7.2

$ pip freeze

Basically, the only Python dependency I installed was Flask because that's what I'm most familiar with. However, the error I'm describing looks to be contained within werkzeug.

Observed Behavior

When using ProfilerMiddleware with its profile_dir argument, the following error gets raised after a request is sent to the server:

Error on request:
Traceback (most recent call last):
  File "/dev/jlove-bazaarvoice/werkzeug-profiler-bug/.venv/lib/python3.7/site-packages/werkzeug/", line 302, in run_wsgi
  File "/dev/jlove-bazaarvoice/werkzeug-profiler-bug/.venv/lib/python3.7/site-packages/werkzeug/", line 290, in execute
    application_iter = app(environ, start_response)
  File "/dev/jlove-bazaarvoice/werkzeug-profiler-bug/.venv/lib/python3.7/site-packages/flask/", line 2309, in __call__
    return self.wsgi_app(environ, start_response)
  File "/dev/jlove-bazaarvoice/werkzeug-profiler-bug/.venv/lib/python3.7/site-packages/werkzeug/middleware/", line 119, in __call__
ValueError: Unknown format code 'd' for object of type 'float'

Expected Behavior

No ValueError.

Steps to Reproduce

  1. pip install flask
  2. Save the following file as
from flask import Flask
from werkzeug.middleware.profiler import ProfilerMiddleware

app = Flask(__name__)
app.wsgi_app = ProfilerMiddleware(app.wsgi_app, profile_dir=".")

@app.route("/", methods=["GET"])
def get_index():
    return "Hello, world!"
  1. Start the server with flask run.
  2. Send a request to the server (e.g.


Slightly modify ProfilerMiddleware's filename_format, replacing the d with f. For example:

app.wsgi_app = ProfilerMiddleware(
    app.wsgi_app, profile_dir=".", filename_format="{method}.{path}.{elapsed:06f}ms.{time:f}.prof"

Both instances of d need to be replaced because both elapsed and time are floating point numbers.

Copy link


Copy link

Dangit. After all the work I put into this issue, it's a dupe. :(

@davidism davidism added this to the 0.15.3 milestone May 8, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
None yet

Successfully merging a pull request may close this issue.

2 participants