Skip to content

Fix github API handling and keyman behavior to correct handling of invalid or missing keys #417

Merged
MoralCode merged 5 commits into
mainfrom
fix/facade_none_keys
Jun 26, 2026
Merged

Fix github API handling and keyman behavior to correct handling of invalid or missing keys #417
MoralCode merged 5 commits into
mainfrom
fix/facade_none_keys

Conversation

@MoralCode

Copy link
Copy Markdown
Contributor

Description
This PR is sort of a catch-all for a couple problems that I suspect were a large part of the cause behind #391

Fix 1: some none handling bugs in keyman
A couple small bugs related to handling of None values in the key handling (keyman) part of the code (improper condition and a bare return statement). Fixed the condition and changed the return to a WaitKeyException to request that the caller sleep for 5 minutes and try again later to see if theres any keys that have refreshed.

Bug 2: Improper handling of 401 HTTP errors in Github API code
The github REST API helper class (GithubDataAccess) was permanently invalidating a key upon receiving a 401 unauthorized response. This was despite the key in question still remaining valid when i manually checked it sometime later. My best guess is its an erroneous/transient error code from github. The way the code handled these errors is contrary to some advice i found online from a github employee suggesting that 401's should be retried a few times after a delay before treating the key as permanently invalidated. So the fix implemented for this is to move that invalidation step outside the retry loop, meaning we only invalidate a key if the unauthorized exception happens on the last retry (suggesting that the 9 prior retries also failed)

Notes for Reviewers
This has been tested repeatedly alongside #415 on a test instance and i dont believe there are issues with it

Signed commits

  • Yes, I signed my commits.

Generative AI disclosure

Please select one option:

  • This contribution was NOT assisted or created by Generative AI tools.
  • This contribution was assisted or created by Generative AI tools.

If AI tools were used, please provide details below:
- What tools were used? Sonnet 4.6 Medium via cursor
- How were these tools used? to the extent they were used at all (i dont remember), it would have been mainly for diagnosing the issue and maybe some incidental in-IDE code completion/helping.
- Did you review these outputs before submitting this PR? yes. i maintained situational awareness and control over every code decision at all times.

…AND that its value is not None

Signed-off-by: Adrian Edwards <adredwar@redhat.com>
…vailable

Signed-off-by: Adrian Edwards <adredwar@redhat.com>
…ing an exception that will invalidate the key

This should help interrupt the facade starvation pipeline.

Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
"Ensure that apps retry the request at least once after receiving a 401 error, but with a slight delay to allow the database to catch up."

https://github.com/orgs/community/discussions/101661#discussioncomment-8342211
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
self.__handle_github_not_authorized_response()
raise last_exception

def _decide_retry_policy(exception: Exception) -> bool:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
E0213: Method '_decide_retry_policy' should have "self" as first argument (no-self-argument)

Comment thread keyman/Orchestrator.py
@@ -156,7 +156,7 @@ def new_key(self, platform: str) -> str | None:
if not len(self.fresh_keys[platform]):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
C1802: Do not use len(SEQUENCE) without comparison to determine if a sequence is empty (use-implicit-booleaness-not-len)

Comment thread keyman/Orchestrator.py
@@ -156,7 +156,7 @@ def new_key(self, platform: str) -> str | None:
if not len(self.fresh_keys[platform]):
if not len(self.expired_keys[platform]):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
C1802: Do not use len(SEQUENCE) without comparison to determine if a sequence is empty (use-implicit-booleaness-not-len)

@MoralCode MoralCode added the high priority Blocking multiple other things, causing data loss, or other incredibly urgent things label Jun 25, 2026
@MoralCode MoralCode added this to the v1.1 Migration Release milestone Jun 26, 2026
@MoralCode MoralCode merged commit b982ac6 into main Jun 26, 2026
16 checks passed
@MoralCode MoralCode deleted the fix/facade_none_keys branch June 26, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

disclosed-ai high priority Blocking multiple other things, causing data loss, or other incredibly urgent things

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant