Skip to content

Commit 4a79626

Browse files
Address PR feedback
1 parent 87a01bc commit 4a79626

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

docassemble/GithubFeedbackForm/github_issue.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,8 @@ def make_github_issue(
371371
body: the body of the GitHub issue
372372
label: optional label to add *if* we can verify or create it
373373
374+
At least one of template, title, and body is required.
375+
374376
Returns:
375377
str, the URL for the label if it exists, or None if the issue could not be created
376378
"""
@@ -413,10 +415,11 @@ def make_github_issue(
413415
apply_label = False # only set to True when we're sure it exists
414416

415417
if label:
416-
labels_url = (
417-
f"https://api.github.com/repos/{repo_owner}/{repo_name}/labels/{label}"
418+
make_labels_url = (
419+
f"https://api.github.com/repos/{repo_owner}/{repo_name}/labels"
418420
)
419-
has_label_resp = requests.get(labels_url, headers=headers)
421+
get_labels_url = f"{make_labels_url}/{label}"
422+
has_label_resp = requests.get(get_labels_url, headers=headers)
420423

421424
if has_label_resp.status_code == 200:
422425
# Label already exists in the repo
@@ -430,7 +433,7 @@ def make_github_issue(
430433
"color": "002E60",
431434
}
432435
make_label_resp = requests.post(
433-
labels_url.rsplit("/", 1)[0], # POST to /labels (collection)
436+
make_labels_url,
434437
data=json.dumps(label_data),
435438
headers=headers,
436439
)
@@ -455,13 +458,18 @@ def make_github_issue(
455458
# ------------------------------------------------------------------
456459
# 2. Derive title/body from a template, if supplied
457460
# ------------------------------------------------------------------
458-
if template and not (title and body):
459-
title = template.subject
460-
body = template.content
461+
if template:
462+
if hasattr(template, "subject"):
463+
title = template.subject
464+
if hasattr(template, "body"):
465+
body = template.content
461466

462-
if not body:
467+
if not title and not body:
463468
return None
464469

470+
if not body:
471+
body = ""
472+
465473
if not title:
466474
title = "User feedback"
467475

0 commit comments

Comments
 (0)