|
21 | 21 | from sweagent.environment.utils import (
|
22 | 22 | PROCESS_DONE_MARKER_END,
|
23 | 23 | PROCESS_DONE_MARKER_START,
|
| 24 | + InvalidGithubURL, |
24 | 25 | copy_anything_to_container,
|
25 | 26 | copy_file_to_container,
|
26 | 27 | format_trajectory_markdown,
|
@@ -811,7 +812,11 @@ def open_pr(self, *, trajectory, _dry_run: bool=False):
|
811 | 812 | # todo: have better way of handling this
|
812 | 813 | # Adding random string suffix to avoid name conflicts if we had a previously failed run
|
813 | 814 | issue_url = self.args.data_path
|
814 |
| - issue = get_gh_issue_data(issue_url, token=self._github_token) |
| 815 | + try: |
| 816 | + issue = get_gh_issue_data(issue_url, token=self._github_token) |
| 817 | + except InvalidGithubURL as e: |
| 818 | + msg = f"Data path must be a github issue URL if --open_pr is set." |
| 819 | + raise ValueError(msg) from e |
815 | 820 | branch_name = f"swe-agent-fix-#{issue.number}-" + str(random.random())[2:10]
|
816 | 821 |
|
817 | 822 | self.communicate_with_handling(
|
@@ -840,6 +845,11 @@ def open_pr(self, *, trajectory, _dry_run: bool=False):
|
840 | 845 | # If `--repo_path` was specified with a different github URL, then the record will contain
|
841 | 846 | # the forking user
|
842 | 847 | assert self.record is not None
|
| 848 | + if not self.record["repo_type"] == "github": |
| 849 | + # We already validated that `--data_path` is a github issue URL |
| 850 | + # so this is the only case where we can reach here |
| 851 | + msg = "--repo_path must point to a github URL if --open_pr is set" |
| 852 | + raise ValueError(msg) |
843 | 853 | forker, _ = self.record["repo"].split("/")
|
844 | 854 | head = branch_name
|
845 | 855 | remote = "origin"
|
|
0 commit comments