Skip to content

Commit

Permalink
fix: fix problem when app token used without installation ID provided (
Browse files Browse the repository at this point in the history
…#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.
  • Loading branch information
TrishGillett authored Aug 15, 2024
1 parent aade338 commit 8c75c9b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion tap_github/authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ def __init__(self, env_key: str, rate_limit_buffer: Optional[int] = None, **kwar
parts = env_key.split(";;")
self.github_app_id = parts[0]
self.github_private_key = (parts[1:2] or [""])[0].replace("\\n", "\n")
self.github_installation_id: Optional[str] = (parts[2:3] or [""])[0]
self.github_installation_id: Optional[str] = (
parts[2] if len(parts) >= 3 else None
)

self.token_expires_at: Optional[datetime] = None
self.claim_token()
Expand Down
2 changes: 1 addition & 1 deletion tap_github/tests/test_authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def test_initialization_with_2_part_env_key(self):
token_manager = AppTokenManager("12345;;key\\ncontent")
assert token_manager.github_app_id == "12345"
assert token_manager.github_private_key == "key\ncontent"
assert token_manager.github_installation_id == ""
assert token_manager.github_installation_id is None

def test_initialization_with_malformed_env_key(self):
expected_error_expression = re.escape(
Expand Down

0 comments on commit 8c75c9b

Please sign in to comment.