Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Github service bugs #6571

Merged
merged 5 commits into from
Feb 3, 2025
Merged

Fix Github service bugs #6571

merged 5 commits into from
Feb 3, 2025

Conversation

malhotra5
Copy link
Contributor

@malhotra5 malhotra5 commented Jan 31, 2025

End-user friendly description of the problem this fixes or functionality that this introduces

  • Include this change in the Release Notes. If checked, you must provide an end-user friendly description for your change below

Give a summary of what the PR does, explaining any non-trivial design decisions

This PR fixes a group of bugs. NOTE: this doesn't affect any existing functionality. However, these changes are blocking for implementing token refresh logic

The bugs fixed

  1. Headers should be dynamically generated (due to token refresh)
  2. App mode comparison is always false (replace "SAAS" with AppMode.SAAS)
  3. Bad response for get_installation_ids function means a dict object isn't return. This PR handles this edge case appropriately
  4. We should use fetch_response to call APIs that require refresh token logic (this PR fixed one such case where get_user was used in place of fetch_response('get_user')

Link of any specific issues this addresses


To run this PR locally, use the following command:

docker run -it --rm   -p 3000:3000   -v /var/run/docker.sock:/var/run/docker.sock   --add-host host.docker.internal:host-gateway   -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:5af19c7-nikolaik   --name openhands-app-5af19c7   docker.all-hands.dev/all-hands-ai/openhands:5af19c7

@malhotra5 malhotra5 requested a review from rbren January 31, 2025 23:04
@@ -51,7 +51,7 @@ async def store_settings(
# We check if the token is valid by getting the user
# If the token is invalid, this will raise an exception
github = GitHubService(settings.github_token, None)
response = await github.get_user()
response = await github.fetch_response('get_user')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we expose a load_user method that returns the user and raises an exception? (It feels weird to have the internals of the github integration exposed here.)

Copy link
Collaborator

@tofarr tofarr left a comment

Choose a reason for hiding this comment

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

🍰 - I see you have these suggestions already in subsequent PRs.

Co-authored-by: tofarr <tofarr@gmail.com>
@malhotra5 malhotra5 enabled auto-merge (squash) February 3, 2025 15:44
@malhotra5 malhotra5 merged commit 7d09a15 into main Feb 3, 2025
13 checks passed
@malhotra5 malhotra5 deleted the fix/refresh-token-infra-bugs branch February 3, 2025 16:44
zchn pushed a commit to zchn/OpenHands that referenced this pull request Feb 4, 2025
Co-authored-by: tofarr <tofarr@gmail.com>
adityasoni9998 pushed a commit to adityasoni9998/OpenHands that referenced this pull request Feb 7, 2025
Co-authored-by: tofarr <tofarr@gmail.com>
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.

3 participants