Skip to content

Commit c90cb8c

Browse files
committed
fix: Address CI/CD errors in create-review-task.py
- Apply black formatting to satisfy CI checks - Fix JSON parsing error by handling gh issue create output correctly - gh issue create returns URL string, not JSON - Extract issue number from URL instead of parsing JSON - Ensure issue number is returned as integer This fixes both CI/CD failures: 1. Black formatting check now passes 2. Script correctly handles gh CLI output format
1 parent 11550b7 commit c90cb8c

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

.conductor/scripts/create-review-task.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ def get_pr_info(pr_number: str, repo: str) -> Dict:
3131
"--repo",
3232
repo,
3333
"--json",
34-
("number,title,body,author,files,additions,deletions,"
35-
"labels,headRefName,baseRefName,isDraft,state"),
34+
(
35+
"number,title,body,author,files,additions,deletions,"
36+
"labels,headRefName,baseRefName,isDraft,state"
37+
),
3638
]
3739
)
3840

@@ -174,15 +176,21 @@ def create_issue(pr_info: Dict, pr_number: str, repo: str, event_type: str) -> i
174176
labels.append(f"effort:{effort}")
175177

176178
# Create the issue
177-
cmd = ["issue", "create", "--repo", repo, "--title", title, "--body", body]
179+
cmd = ["gh", "issue", "create", "--repo", repo, "--title", title, "--body", body]
178180

179181
for label in labels:
180182
cmd.extend(["--label", label])
181183

182-
result = run_gh_command(cmd)
183-
issue_number = result.get("number")
184-
185-
print(f"✅ Created review task issue #{issue_number}")
184+
try:
185+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
186+
# gh issue create returns the issue URL, extract the number
187+
issue_url = result.stdout.strip()
188+
issue_number = issue_url.split("/")[-1]
189+
print(f"✅ Created review task issue #{issue_number}")
190+
except subprocess.CalledProcessError as e:
191+
print(f"Error creating issue: {e}")
192+
print(f"stderr: {e.stderr}")
193+
sys.exit(1)
186194

187195
# Add comment to PR linking to review task
188196
comment = f"""🤖 **Code Review Task Created**
@@ -199,14 +207,12 @@ def create_issue(pr_info: Dict, pr_number: str, repo: str, event_type: str) -> i
199207
check=True,
200208
)
201209

202-
return issue_number
210+
return int(issue_number)
203211

204212

205213
def main():
206214
parser = argparse.ArgumentParser(description="Create code review task from PR")
207-
parser.add_argument(
208-
"--pr-number", required=True, help="Pull request number"
209-
)
215+
parser.add_argument("--pr-number", required=True, help="Pull request number")
210216
parser.add_argument("--repo", required=True, help="Repository (owner/name)")
211217
parser.add_argument(
212218
"--event-type",

0 commit comments

Comments
 (0)