Skip to content

Commit

Permalink
Merge pull request #1472 from pallets/debugger-pin
Browse files Browse the repository at this point in the history
ignore getuser KeyError for debugger pin
  • Loading branch information
davidism authored Mar 13, 2019
2 parents f61d269 + ed4bf43 commit 03c81ae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ Unreleased
incorrectly classify some frames. (:pr:`1421`)
- Clicking the error message at the top of the interactive debugger
will jump down to the bottom of the traceback. (:pr:`1422`)
- When generating a PIN, the debugger will ignore a ``KeyError``
raised when the current UID doesn't have an associated username,
which can happen in Docker. (:issue:`1471`)
- :class:`~exceptions.BadRequestKeyError` adds the ``KeyError``
message to the description, making it clearer what caused the 400
error. Frameworks like Flask can omit this information in production
Expand Down
7 changes: 4 additions & 3 deletions src/werkzeug/debug/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,11 @@ def get_pin_and_cookie_name(app):
modname = getattr(app, "__module__", getattr(app.__class__, "__module__"))

try:
# `getpass.getuser()` imports the `pwd` module,
# which does not exist in the Google App Engine sandbox.
# getuser imports the pwd module, which does not exist in Google
# App Engine. It may also raise a KeyError if the UID does not
# have a username, such as in Docker.
username = getpass.getuser()
except ImportError:
except (ImportError, KeyError):
username = None

mod = sys.modules.get(modname)
Expand Down

0 comments on commit 03c81ae

Please sign in to comment.