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

refactor: Update get_github_installation_ids to use httpx #6451

Merged
merged 3 commits into from
Jan 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions openhands/server/routes/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,19 @@ async def get_github_installation_ids(
):
headers = generate_github_headers(github_token)
try:
response = await call_sync_from_async(
requests.get, 'https://api.github.com/user/installations', headers=headers
)
response.raise_for_status()
except requests.exceptions.RequestException as e:
async with httpx.AsyncClient() as client:
response = await client.get('https://api.github.com/user/installations', headers=headers)
response.raise_for_status()
data = response.json()
ids = [installation['id'] for installation in data['installations']]
return JSONResponse(content=ids)

except httpx.HTTPError as e:
raise HTTPException(
status_code=response.status_code if response else 500,
status_code=e.response.status_code if hasattr(e, 'response') else 500,
detail=f'Error fetching installations: {str(e)}',
)

data = response.json()
ids = [installation['id'] for installation in data['installations']]
json_response = JSONResponse(content=ids)
response.close()

return json_response


@app.get('/search/repositories')
async def search_github_repositories(
Expand Down
Loading