Skip to content

Commit 8c75c9b

Browse files
authored
fix: fix problem when app token used without installation ID provided (#291)
Addresses the problem described by @camerondavison [here](#284 (comment)), and introduced in #284. If not provided, installation ID should be set to None, since that is the way `generate_app_access_token` expects a missing installation ID to be represented.
1 parent aade338 commit 8c75c9b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

tap_github/authenticator.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ def __init__(self, env_key: str, rate_limit_buffer: Optional[int] = None, **kwar
167167
parts = env_key.split(";;")
168168
self.github_app_id = parts[0]
169169
self.github_private_key = (parts[1:2] or [""])[0].replace("\\n", "\n")
170-
self.github_installation_id: Optional[str] = (parts[2:3] or [""])[0]
170+
self.github_installation_id: Optional[str] = (
171+
parts[2] if len(parts) >= 3 else None
172+
)
171173

172174
self.token_expires_at: Optional[datetime] = None
173175
self.claim_token()

tap_github/tests/test_authenticator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def test_initialization_with_2_part_env_key(self):
135135
token_manager = AppTokenManager("12345;;key\\ncontent")
136136
assert token_manager.github_app_id == "12345"
137137
assert token_manager.github_private_key == "key\ncontent"
138-
assert token_manager.github_installation_id == ""
138+
assert token_manager.github_installation_id is None
139139

140140
def test_initialization_with_malformed_env_key(self):
141141
expected_error_expression = re.escape(

0 commit comments

Comments
 (0)