OpenHands
OpenHands copied to clipboard
Add enhanced logging for error paths in add-git-providers endpoint
Description
This PR adds enhanced logging for error paths in the add-git-providers endpoint, with a particular focus on HTTP errors.
Changes
- Added detailed logging in
validate_provider_tokenfunction to capture HTTP errors with status codes and response content - Enhanced error handling in
check_provider_tokensfunction with try/except blocks and more detailed logging - Added specific HTTP error handling in the
store_provider_tokensendpoint - Improved logging throughout the token validation process
- Changed log level from
infotowarningorerrorfor error conditions
Testing
The changes have been tested with the pre-commit hooks to ensure code quality.
Impact
These changes will make it easier to diagnose issues with git provider token validation by providing more detailed logs, especially for HTTP errors.
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:c89e726-nikolaik --name openhands-app-c89e726 docker.all-hands.dev/all-hands-ai/openhands:c89e726
@openhands move the logging into the GitHubService and GitLabService. Make sure the hostname/urls being used get logged too
I'm on it! rbren can track my progress at all-hands.dev
I've successfully moved the logging from the validate_provider_token function into the GitHubService and GitLabService classes, and added hostname/URL information to the logs.
Here's a summary of the changes made:
-
Enhanced the
GitHubServiceclass:- Added logging in the
__init__method to log the base URL being used - Added detailed logging in the
verify_accessmethod with URL information - Added proper error handling with specific log messages for different error types
- Added logging in the
-
Enhanced the
GitLabServiceclass:- Added logging in the
__init__method to log both the base URL and GraphQL URL - Added detailed logging in the
get_usermethod with URL information - Added proper error handling with specific log messages for different error types
- Added logging in the
-
Simplified the
validate_provider_tokenfunction inutils.py:- Removed redundant logging since it's now handled in the service classes
- Removed unnecessary imports
-
Fixed all code quality issues and ensured the pre-commit hooks pass
These changes will make it easier to diagnose issues with git provider token validation by providing more detailed logs that include the hostname/URLs being used, especially for HTTP errors.
The changes have been successfully pushed to the improve-git-providers-logging branch, updating PR #8890.
Looks like there are a few issues preventing this PR from being merged!
- GitHub Actions are failing:
- Docker
If you'd like me to help, just leave a comment, like
@OpenHands please fix the failing actions on PR #8890
Feel free to include any additional details that might help me get this PR into a better state.
You can manage your notification settings
@rbren it seems like there's a bunch of test failures and merge conflicts to handle here, I'm setting this as a draft and keeping you assigned, but tell us if you'd like someone to take over.