You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by ak...@apache.org on 2026/05/22 03:03:51 UTC

(tooling-trusted-releases) 01/05: Fix WriteAsFoundationAdmin construction-time AttributeError

This is an automated email from the ASF dual-hosted git repository.

andrewmusselman pushed a commit to branch fix-broken-e2e-tests
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git

commit 11a2c2ccf145f2610633c8e73025fff9674d7392
Author: Andrew Musselman <ak...@apache.org>
AuthorDate: Thu May 21 19:48:44 2026 +0000

    Fix WriteAsFoundationAdmin construction-time AttributeError
    
    When WriteAsFoundationAdmin is constructed, super().__init__() runs
    WriteAsFoundationCommitter.__init__, which creates a notifications
    writer with the line:
    
        self.notifications = writers.notifications.FoundationCommitter(
            write, self, data
        )
    
    The 'self' argument is the WriteAsFoundationAdmin instance being
    constructed. The notifications writer's __init__ reads write_as.asf_uid,
    which via Python method resolution finds the WriteAsFoundationAdmin
    asf_uid property override (most-derived wins). That property reads
    self.__asf_uid, name-mangled to self._WriteAsFoundationAdmin__asf_uid.
    That attribute is assigned on the line after super().__init__() returns,
    so at the moment the property is called the attribute does not yet
    exist:
    
        AttributeError: 'WriteAsFoundationAdmin' object has no attribute
        '_WriteAsFoundationAdmin__asf_uid'
    
    Causes admin-only endpoints to 500 in production paths that go through
    WriteAsFoundationAdmin, including POST /revoke-user-ssh-keys and POST
    /revoke-user-tokens (e2e/admin/test_revoke_ssh_keys.py and
    e2e/admin/test_revoke_tokens.py).
    
    The WriteAsFoundationAdmin __asf_uid and asf_uid property override are
    redundant with the parent's identical definitions, so the fix is just
    to remove them and inherit. The parent assigns
    _WriteAsFoundationCommitter__asf_uid before constructing any writers,
    so the property is safe to read during writer construction.
---
 atr/storage/__init__.py | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/atr/storage/__init__.py b/atr/storage/__init__.py
index 0f5ae18e..fab2a9a8 100644
--- a/atr/storage/__init__.py
+++ b/atr/storage/__init__.py
@@ -230,18 +230,17 @@ class WriteAsCommitteeMember(WriteAsCommitteeParticipant):
 
 class WriteAsFoundationAdmin(WriteAsFoundationCommitter):
     def __init__(self, write: Write, data: db.Session):
+        # __asf_uid and the asf_uid property are inherited from
+        # WriteAsFoundationCommitter. Defining our own here previously caused
+        # an AttributeError during construction: super().__init__() creates
+        # writers (notably notifications) that read write_as.asf_uid, which
+        # via MRO resolves to this class's property override, which reads
+        # _WriteAsFoundationAdmin__asf_uid, which had not yet been assigned.
         super().__init__(write, data)
-        self.__asf_uid = write.authorisation.asf_uid
         self.release = writers.release.FoundationAdmin(write, self, data)
         self.tokens = writers.tokens.FoundationAdmin(write, self, data)
         self.ssh = writers.ssh.FoundationAdmin(write, self, data)
 
-    @property
-    def asf_uid(self) -> str:
-        if self.__asf_uid is None:
-            raise AccessError("Not authorized", status=403)
-        return self.__asf_uid
-
 
 class WriteAsCommitteeAdmin(WriteAsCommitteeMember):
     def __init__(self, write: Write, data: db.Session, committee_key: str):


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org