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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Fix Github service bugs #6571

wants to merge 2 commits into from

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:8d314e3-nikolaik   --name openhands-app-8d314e3   docker.all-hands.dev/all-hands-ai/openhands:8d314e3

@malhotra5 malhotra5 requested a review from rbren January 31, 2025 23:04
@@ -66,6 +72,9 @@ async def get_installation_ids(self):
url = f'{self.BASE_URL}/user/installations'
response = await self._fetch_data(url)
data = response.json()
if not isinstance(data, dict): # Ensure data is a dictionary
return []
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return []
return {}

right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

or maybe we want isinstance(data, list)?

Copy link
Contributor Author

@malhotra5 malhotra5 Feb 1, 2025

Choose a reason for hiding this comment

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

I believe the code is correct; the Github API returns a dict

data = {"installations": [{"id": 3}], "app_slug": .....}

The frontend expects the list of just installation IDs, however, so we return data.get('installations', [])

The return statement of this function reflects this requirement

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh I see it now, thanks

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.

2 participants