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 issue #5448: When using the GitHub resolver on a PR, automatically pipe in failure info #5449

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

Conversation

openhands-agent
Copy link
Contributor

@openhands-agent openhands-agent commented Dec 7, 2024

This PR addresses the issue reported in the comment #5449 (comment)

Changes made:

  1. Modified get_instruction method in PRHandler class to include a message when there are no merge conflicts and all CI checks have passed.
  2. Updated test_get_instruction_without_pr_status test case to check for the new message.
  3. Ran pre-commit hooks and made necessary formatting changes.

Please review the changes and let me know if any further modifications are needed.


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

Copy link
Contributor

@neubig neubig left a comment

Choose a reason for hiding this comment

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

@openhands-agent the python linting GitHub workflow is failing. Please check the workflow file and make sure that linking passes.

@neubig
Copy link
Contributor

neubig commented Dec 7, 2024

I'm still working on validating this, which is bringing out a bunch of little issues. No need to review yet.

@neubig neubig self-requested a review December 7, 2024 21:26
@neubig neubig self-assigned this Dec 9, 2024
Copy link
Contributor

neubig commented Dec 25, 2024

Correction and update on the validation test for this PR:

I apologize for the confusion in my previous comment. After further investigation and fixes, here are the corrected results:

  1. We identified an issue where duplicate lint failures were being reported in the PR status.
  2. The problem was in the __get_pr_status method of the PRHandler class, which was returning duplicate entries for failed checks.
  3. We fixed this issue by modifying the __get_pr_status method to use a unique_check_names set to prevent duplicates.

After applying these changes, the test results now correctly show:

PR Status:

The following CI checks have failed:
- lint: No description available

Please examine the GitHub workflow files, reproduce the problem locally, and fix and test it locally.

This update ensures that the OpenHands resolver accurately reports PR status issues without duplication, further improving its functionality in addressing the original issue (#5448).

The changes made to resolve the issue:

  1. Modified the __get_pr_status method to use a unique_check_names set to keep track of unique check names and prevent duplicates.
  2. Updated the logic to only add a failed check to the failed_checks list if its name is not already in the unique_check_names set.

These modifications have successfully resolved the issue of duplicate lint failures being reported in the PR status, ensuring that the implementation correctly addresses the original requirements.

@neubig neubig marked this pull request as ready for review December 25, 2024 22:51
@neubig neubig requested a review from malhotra5 December 25, 2024 22:52
Copy link
Contributor

@neubig neubig left a comment

Choose a reason for hiding this comment

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

LGTM but need a second review.

@neubig
Copy link
Contributor

neubig commented Dec 28, 2024

Actually, I tried to run this locally, and got the following error. We should see if we can reproduce this and fix.

$ poetry run python -m openhands.resolver.resolve_issue --repo neubig/pr-viewer --issue-number 14 --username neubig --issue-type pr
14:20:24 - openhands:INFO: issue_definitions.py:643 - Limiting resolving to issues [14].
ERROR:root:  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/gneubig/work/OpenHands/openhands/resolver/resolve_issue.py", line 655, in <module>
    main()
  File "/Users/gneubig/work/OpenHands/openhands/resolver/resolve_issue.py", line 634, in main
    asyncio.run(
  File "/Users/gneubig/miniconda3/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/Users/gneubig/miniconda3/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gneubig/miniconda3/lib/python3.12/asyncio/base_events.py", line 685, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Users/gneubig/work/OpenHands/openhands/resolver/resolve_issue.py", line 343, in resolve_issue
    issues: list[GithubIssue] = issue_handler.get_converted_issues(
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gneubig/work/OpenHands/openhands/resolver/issue_definitions.py", line 681, in get_converted_issues
    issue_details = GithubIssue(
                    ^^^^^^^^^^^^
  File "/Users/gneubig/Library/Caches/pypoetry/virtualenvs/openhands-ai-mHbwbJq6-py3.12/lib/python3.12/site-packages/pydantic/main.py", line 212, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ERROR:root:<class 'pydantic_core._pydantic_core.ValidationError'>: 2 validation errors for GithubIssue
failed_checks.0.description
  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.9/v/string_type
failed_checks.1.description
  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.9/v/string_type

neubig and others added 12 commits December 28, 2024 14:30
1. Add pr_status section to basic-followup.jinja template
2. Add unit tests to verify PR status in prompts
Update test assertions to match new behavior where 'This PR has no merge conflicts' is only included when there's already some status information.
1. Add check to avoid duplicate CI check entries
2. Remove separate linting section since it's redundant with CI check information
3. Update tests to match new behavior
@neubig
Copy link
Contributor

neubig commented Dec 29, 2024

OK, I've confirmed this is working, I get the below prompt when linting is failing:

The current code is an attempt at fixing one or more issues. The code is not satisfactory and follow up feedback have been provided to address this.
The feedback may be addressed to specific code files. In this case the file locations will be provided.
Please update the code based on the feedback for the repository in /workspace.
An environment has been set up for you to start working. You may assume all necessary tools are installed.

# Issues addressed
[
    "It would nice to be able to sort the retrieved PRs. Add an option to retrieve the sorted PRs by various characteristics."
]


# PR Status
The following CI checks have failed:
- lint: No description provided
Please examine the GitHub workflow files, reproduce the problem locally, and fix and test it locally.
Please run the failing checks locally to fix the issues.

Note: Detailed information about the failed checks is not available. Please check the GitHub Actions tab for more information.


# Review comments
None

# Review threads
None

# Review thread files
None

# PR Thread Comments


IMPORTANT: You should ONLY interact with the environment provided to you AND NEVER ASK FOR HUMAN HELP.
You SHOULD INCLUDE PROPER INDENTATION in your edit commands.

When you think you have fixed the issue through code changes, please finish the interaction.

@neubig neubig assigned malhotra5 and unassigned neubig Dec 29, 2024
import logging
import traceback
from openhands.resolver.issue_definitions import PRHandler
from openhands.core.config import LLMConfig
Copy link
Collaborator

Choose a reason for hiding this comment

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

Was the inclusion of this file intended?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm guessing not, but this file is great! I wonder if we could convert it into an integration test 🤔


# Print raw API response for debugging
print(f'Raw API response for PR #{pull_number}:')
print(json.dumps(response_json, indent=2))
Copy link
Collaborator

Choose a reason for hiding this comment

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

We probably don't need these prints anymore


print(f'Processed PR status for PR #{pull_number}:')
print(f'has_conflicts: {has_conflicts}')
print(f'failed_checks: {failed_checks}')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here too, I suppose?

thread_ids: Optional[list[str]] = None
head_branch: Optional[str] = None
has_merge_conflicts: Optional[bool] = None
failed_checks: Optional[list[dict[str, Optional[str]]]] = None
Copy link
Collaborator

Choose a reason for hiding this comment

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

@openhands-agent In this PR, look at the diff for the file github_issue.py.

IMPORTANT: we use python 3.10+ and so we use | None, instead of the old Optional. Please make sure that this file does that too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Openhands fix success summary

Unable to verify the implementation of the requested changes because the actual code changes in github_issue.py are not provided. While the AI agent claims to have updated the type hints to use Python 3.10+ style (| None instead of Optional), removed the Optional import, and fixed nested type hints, we need to see the actual code diff to confirm these changes were made correctly.

@openhands-agent
Copy link
Contributor Author

OpenHands started fixing the pr! You can monitor the progress here.

@@ -296,6 +296,129 @@ def __init__(self, owner: str, repo: str, token: str, llm_config: LLMConfig):
super().__init__(owner, repo, token, llm_config)
self.download_url = 'https://api.github.com/repos/{}/{}/pulls'

def __get_pr_status(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it really intentional to use a double underscore here?

@openhands-agent
Copy link
Contributor Author

Overview:
Status: UNRESOLVED ❌

The changes cannot be verified because:

  • No actual code changes or diffs were provided
  • Only a description of intended changes was given without implementation details

To properly assess the resolution, we would need to see:

  • The actual code changes in github_issue.py
  • Before/after comparison of the type hint modifications
  • Confirmation that the Optional import was removed
  • Verification of the nested type hint fixes

Recommendation:
Please provide the actual code changes to verify the implementation of the requested modifications.

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.

4 participants