Skip to content

Conversation

@jayClean
Copy link

@jayClean jayClean commented Dec 9, 2025

Fix AttributeError when pin_security=False (#3075)

Starting with werkzeug 3.1.4, initializing DebuggedApplication with
pin_security=False raises an AttributeError because the pin setter
attempts to delete self._pin before it has been initialized.

The issue occurs in __init__ when pin_security=False: it calls
self.pin = None, which triggers the setter that tries to execute
del self._pin. Since _pin hasn't been created yet (it's lazily
initialized by the getter), this raises an AttributeError.

The fix changes the setter to explicitly set _pin = None instead of
deleting it. This prevents the error and ensures that when pin security
is disabled, the pin remains None and doesn't get regenerated by the
lazy getter. The type annotation for _pin is also updated from str
to str | None to reflect that it can be None.

#3075
fixes #3075

  • Added test case test_debugged_application_pin_security_false() that
    verifies DebuggedApplication can be initialized with pin_security=False
    without raising an error. The test would fail before the fix.

  • Updated type annotation for _pin from str to str | None to allow
    None values.

  • Added entry in CHANGES.rst under Version 3.2.0 (Unreleased) section.

  • No documentation changes needed as the behavior is now correct and
    matches the documented API.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DebugApplication(..., pin_security=False) no longer works

1 participant