OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

Add enhanced logging for error paths in add-git-providers endpoint

Open rbren opened this issue 5 months ago • 4 comments

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_token function to capture HTTP errors with status codes and response content
  • Enhanced error handling in check_provider_tokens function with try/except blocks and more detailed logging
  • Added specific HTTP error handling in the store_provider_tokens endpoint
  • Improved logging throughout the token validation process
  • Changed log level from info to warning or error for 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

rbren avatar Jun 04 '25 15:06 rbren

@openhands move the logging into the GitHubService and GitLabService. Make sure the hostname/urls being used get logged too

rbren avatar Jun 06 '25 20:06 rbren

I'm on it! rbren can track my progress at all-hands.dev

openhands-ai[bot] avatar Jun 06 '25 20:06 openhands-ai[bot]

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:

  1. Enhanced the GitHubService class:

    • Added logging in the __init__ method to log the base URL being used
    • Added detailed logging in the verify_access method with URL information
    • Added proper error handling with specific log messages for different error types
  2. Enhanced the GitLabService class:

    • Added logging in the __init__ method to log both the base URL and GraphQL URL
    • Added detailed logging in the get_user method with URL information
    • Added proper error handling with specific log messages for different error types
  3. Simplified the validate_provider_token function in utils.py:

    • Removed redundant logging since it's now handled in the service classes
    • Removed unnecessary imports
  4. 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.

openhands-ai[bot] avatar Jun 06 '25 20:06 openhands-ai[bot]

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

openhands-ai[bot] avatar Jun 06 '25 21:06 openhands-ai[bot]

@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.

neubig avatar Jun 23 '25 18:06 neubig