Skip to content

πŸ™Œ OpenHands: AI-Driven Development

refactor: infer issue readiness type from body instead of label (#16955)

OpenHands Bot1a6babd445ff
diff --git a/.github/scripts/check_issue_readiness.py b/.github/scripts/check_issue_readiness.py
index 7c5e3a911b..d2ca83534e 100644
--- a/.github/scripts/check_issue_readiness.py
+++ b/.github/scripts/check_issue_readiness.py
@@ -1,16 +1,18 @@
"""Determine whether an issue meets the `ready-for-dev` readiness criteria.
-The criteria are type-specific:
+The criteria are type-specific, and the type is inferred from the body
+structure rather than the `bug`/`enhancement` label:
-- Bug reports (labeled `bug`): the Steps to Reproduce section must reference at
- least one supported run method (`agent-canvas`, `npm run`, or
- `app.all-hands.dev/canvas`), the Actual Behavior section must embed a
- screenshot or video, and there must be a non-empty Acceptance Criteria
- section with at least one checklist item.
+- Bug reports (a `##`/`### Steps to Reproduce` or `##`/`### Actual Behavior`
+ section):
+ the Steps to Reproduce section must reference at least one supported run
+ method (`agent-canvas`, `npm run`, or `app.all-hands.dev/canvas`), the
+ Actual Behavior section must embed a screenshot or video, and there must be
+ a non-empty Acceptance Criteria section with at least one checklist item.
-- Enhancements (labeled `enhancement`): the body must contain non-empty
- Desired Behavior and Acceptance Criteria sections, the latter with at least
- one checklist item.
+- Enhancements (a `##`/`### Desired Behavior` section): the body must contain
+ non-empty Desired Behavior and Acceptance Criteria sections, the latter
+ with at least one checklist item.
GitHub issue forms render each field as an `### <Label>` (h3) heading followed
by the field text, with empty optional fields rendered as `_No response_`. The
@@ -19,8 +21,7 @@ issues, and checks each criterion against the corresponding section.
Local usage:
- python .github/scripts/check_issue_readiness.py --body-file /tmp/issue.md \
- --labels bug
+ python .github/scripts/check_issue_readiness.py --body-file /tmp/issue.md
python .github/scripts/check_issue_readiness.py --event-path "$GITHUB_EVENT_PATH"
"""
@@ -39,18 +40,26 @@ from markdown_sections import find_headings
BUG_LABEL = "bug"
ENHANCEMENT_LABEL = "enhancement"
+# Issue-form field headings that identify an issue's type. The `bug` and
+# `enhancement` labels are deliberately not consulted: the type is inferred from
+# which of these sections is present, so issues can qualify for `ready-for-dev`
+# without carrying a label.
+BUG_SECTION_LABELS = (
+ "actual behavior",
+ "actual",
+ "steps to reproduce",
+ "reproduction",
+)
+ENHANCEMENT_SECTION_LABELS = ("desired behavior", "desired")
+
# Issue-form fields render as h3 headings, while hand-edited and free-form
# issues commonly use h2. Capture the level so nested h3 headings can remain
# part of an h2 section.
HEADING_RE = re.compile(r"(?m)^(?P<level>#{2,3})\s+(?P<title>.+?)\s*$")
READINESS_SECTION_LABELS = {
- "steps to reproduce",
- "reproduction",
- "actual behavior",
- "actual",
- "desired behavior",
- "desired",
+ *BUG_SECTION_LABELS,
+ *ENHANCEMENT_SECTION_LABELS,
"acceptance criteria",
"acceptance",
}
@@ -232,25 +241,28 @@ def check_enhancement(sections: dict[str, str]) -> ReadinessResult:
def evaluate_readiness(body: str, labels: list[str]) -> ReadinessResult:
- """Return the readiness result for an issue body + label set.
+ """Return the readiness result for an issue body.
- An issue is only a candidate when it carries the `bug` or `enhancement`
- label. If it has neither, it is treated as not-ready-for-dev (the gate does
- not apply a label it cannot validate).
+ The type is inferred from the body structure, not the `bug`/`enhancement`
+ label: a body with a `##`/`### Steps to Reproduce` or `##`/`### Actual
+ Behavior` section is treated as a bug report, and a body with a
+ `##`/`### Desired Behavior` section is treated as an enhancement. `labels`
+ is accepted for backwards compatibility but is not consulted.
"""
- label_set = {label.lower() for label in labels}
sections = extract_sections(body or "")
- if BUG_LABEL in label_set:
+ if any(label in sections for label in BUG_SECTION_LABELS):
return check_bug(sections)
- if ENHANCEMENT_LABEL in label_set:
+ if any(label in sections for label in ENHANCEMENT_SECTION_LABELS):
return check_enhancement(sections)
return ReadinessResult(
ready=False,
reasons=[
- "The issue has neither the `bug` nor `enhancement` label, so its "
- "readiness criteria cannot be evaluated. Add the appropriate label."
+ "The issue has neither a `### Steps to Reproduce`/`### Actual "
+ "Behavior` nor a `### Desired Behavior` section, so its readiness "
+ "criteria cannot be evaluated. Use the bug report or feature "
+ "request template."
],
)
@@ -273,7 +285,8 @@ def parse_args() -> argparse.Namespace:
parser.add_argument("--body-file", type=Path, help="Read the issue body from a file.")
parser.add_argument(
"--labels",
- help="Comma-separated issue labels (e.g. 'bug,frontend').",
+ help="Comma-separated issue labels. Accepted for backwards compatibility "
+ "but no longer consulted (the type is inferred from the body).",
default="",
)
parser.add_argument(
diff --git a/.github/scripts/post-readiness-comment.mjs b/.github/scripts/post-readiness-comment.mjs
index 5fb82ef3e8..2666ed09b1 100644
--- a/.github/scripts/post-readiness-comment.mjs
+++ b/.github/scripts/post-readiness-comment.mjs
@@ -144,15 +144,15 @@ async function main() {
"",
"This issue does not yet meet the readiness criteria, so the",
"`ready-for-dev` label has not been applied (or has been removed).",
- "The criteria are type-specific:",
+ "The criteria are type-specific, and the type is inferred from the body:",
"",
- "**Bug reports** (`bug` label):",
+ "**Bug reports** (a `##`/`### Steps to Reproduce` or `##`/`### Actual Behavior` section):",
"- The `### Steps to Reproduce` section must reference a supported run method",
" (`agent-canvas`, `npm run`, or `app.all-hands.dev/canvas`).",
"- The `### Actual Behavior` section must include a screenshot or video of the bug.",
"- An `### Acceptance Criteria` section with at least one checklist item (`- [ ] …`).",
"",
- "**Enhancements** (`enhancement` label):",
+ "**Enhancements** (a `##`/`### Desired Behavior` section):",
"- A `### Desired Behavior` section.",
"- An `### Acceptance Criteria` section with at least one checklist item.",
"",
diff --git a/.github/scripts/tests/test_issue_readiness.py b/.github/scripts/tests/test_issue_readiness.py
index 1dd6961fc2..615134ad6c 100644
--- a/.github/scripts/tests/test_issue_readiness.py
+++ b/.github/scripts/tests/test_issue_readiness.py
@@ -196,15 +196,37 @@ def test_enhancement_not_ready_prose_acceptance():
# ---------------------------------------------------------------------------
-# No type label
+# No type section
# ---------------------------------------------------------------------------
-def test_no_type_label_not_ready():
- result = evaluate_readiness("### Something\nSome text", ["frontend"])
+def test_no_type_section_not_ready():
+ result = evaluate_readiness("### Something\nSome text", [])
assert not result.ready
assert any("neither" in r.lower() for r in result.reasons)
+def test_type_inferred_from_body_ignores_labels():
+ # A bug-shaped body is treated as a bug even without a `bug` label.
+ result = evaluate_readiness(BUG_BODY_READY, [])
+ assert result.ready, result.reasons
+
+ # A feature-shaped body is treated as an enhancement even with a `bug` label.
+ result = evaluate_readiness(ENHANCEMENT_BODY_READY, ["bug"])
+ assert result.ready, result.reasons
+
+ # A body with only an `### Actual Behavior` section (no Steps to Reproduce)
+ # is still recognized as a bug report.
+ result = evaluate_readiness(BUG_BODY_MISSING_REPRODUCTION, [])
+ assert not result.ready
+ assert any("Steps to Reproduce" in r for r in result.reasons)
+
+
+def test_empty_type_section_is_still_classified():
+ result = evaluate_readiness("### Actual Behavior\n### Acceptance Criteria\n", [])
+ assert not result.ready
+ assert any("Steps to Reproduce" in r for r in result.reasons)
+
+
# ---------------------------------------------------------------------------
# Unit-level helpers
# ---------------------------------------------------------------------------
@@ -260,7 +282,7 @@ def test_extract_sections():
def test_bug_ready_with_h2_sections():
body = BUG_BODY_READY.replace("### ", "## ")
- result = evaluate_readiness(body, [BUG_LABEL])
+ result = evaluate_readiness(body, [])
assert result.ready, result.reasons
@@ -480,4 +502,3 @@ def test_main_event_path_json_ready(tmp_path, capsys, monkeypatch):
assert data["ready"] is True
assert len(data["reasons"]) == 0
-
diff --git a/.github/workflows/issue-readiness-check.yml b/.github/workflows/issue-readiness-check.yml
index 35524e3f3c..9fa5a4aba9 100644
--- a/.github/workflows/issue-readiness-check.yml
+++ b/.github/workflows/issue-readiness-check.yml
@@ -3,14 +3,10 @@ name: Issue Readiness Check
# Manages the `ready-for-dev` label based on type-specific readiness criteria.
#
-# Bug reports (label `bug`): the Steps to Reproduce section must reference a
-# supported run method (`agent-canvas`, `npm run`, or
-# `app.all-hands.dev/canvas`), the Actual Behavior section must embed a
-# screenshot or video, plus an Acceptance Criteria section with at least one
-# checklist item.
-#
-# Enhancements (label `enhancement`): the body must contain Desired Behavior and
-# Acceptance Criteria sections, the latter with at least one checklist item.
+# The type is inferred from the issue body rather than its labels: a body with
+# a `##`/`### Steps to Reproduce` or `##`/`### Actual Behavior` section is
+# checked as a bug report, and a body with a `##`/`### Desired Behavior`
+# section is checked as an enhancement. The criteria themselves are unchanged.
#
# When criteria are met the label is added (idempotently); when they are not the
# label is removed. A feedback comment is posted (or updated) in three cases: