8000 Detect issue type from template for API generated issues without labels by ahus1 · Pull Request #85 · keycloak/keycloak-github-bot · GitHub
[go: up one dir, main page]

Skip to content

Detect issue type from template for API generated issues without labels - #85

Merged
stianst merged 2 commits into
keycloak:mainfrom
ahus1:is-84-detect-kind-from-body
Dec 1, 2026
Merged

stianst merged 2 commits into
keycloak:mainfrom
ahus1:is-84-detect-kind-from-body

Conversation

@ahus1
@ahus1 ahus1 commented Sep 24, 2026 •
Copy link
Copy Markdown
Member

Closes #84

Issues created via the GitHub API or gh --template carry no labels, so triage never starts. The bot now derives the labels from the template structure in the issue body.

Decisions and assumptions:

  • Both template generations are supported, see IssueParser.detectTemplateType(): the ones before Make it possible to identify the issue template used when labels are not added keycloak#55144 and the ones after, which have a distinct description header per type.
  • Legacy enhancement and feature templates are identical, so they are labeled as kind/enhancement. The triager can change this to a feature.
  • Bugs get kind/bug, status/triage and the area/ label; enhancements and features get their kind/ label and status/triage; tasks get kind/task only, as in the template.
  • Issues that already have any kind/ label are left untouched, as are issues that match no template.
  • The GitHub issue type is not set yet, only the labels.

Tested with a test GitHub App on a fork with the upstream templates and labels. Issues created via the API without labels were labeled as expected:

@ahus1
ahus1 commented Sep 24, 2026
Copy link
Copy Markdown
Member Author

@stianst - this is a suggestion on how to approach this. It does not yet set the GitHub issue type, just the label.

Pleaes let me know if you agree with the approach, and if it needs refinement.

@stianst
stianst commented Nov 13, 2026
Copy link
Copy Markdown
Collaborator

For some reason I was sure that GH CLI supported issue templates, but it doesn't (well barely does). So, you are correct on this one.

I propose we make it explicit in the templates what issue type it is for so we can identify all issue templates:
keycloak/keycloak#55144

This might be taking it one step to far, but maybe we should also validate new issues match a template, and provides all the required fields? If it doesn't we auto-close.

@ahus1
ahus1 force-pushed the is-84-detect-kind-from-body branch from 3d2ae77 to 3d38751 Compare November 13, 2026 14:53
8000
@ahus1
ahus1 requested a review from stianst November 13, 2026 14:59
@ahus1
ahus1 commented Nov 13, 2026 •
Copy link
Copy Markdown
Member Author

@stianst - the issues we receive are usually quite good, so wouldn't auto-close them. I assume we'll soon have a bot that identifies the type and area when the simple pattern doesn't suffice.

I tested this against my repository, and it should be good for merging. Evidence linked in the body.

Copilot AI left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Substring matching in IssueParser misclassifies bug-heading text in prose or code, causing incorrect labels; heading-aware detection and regression tests are needed.

1 open issue
What changed in this PR

This PR addresses #84 by deriving labels from issue-template bodies, allowing API- and CLI-created issues without kind labels to enter the bot’s triage workflow.

Changes:

  • Detects current template types and legacy bug/enhancement templates.
  • Applies kind and triage labels as appropriate, retaining area labeling for bugs.
  • Adds parser and handler tests with template and plain-body fixtures.
File Description
src/​main/​java/​org/​keycloak/​gh/​bot/​AddAreaLabelToBugs.java Applies labels based on detected template type.
src/​main/​java/​org/​keycloak/​gh/​bot/​utils/​IssueParser.java Detects current and legacy template structures.
src/​main/​java/​org/​keycloak/​gh/​bot/​utils/​Labels.java Adds kind constants and prefix matching.
src/​test/​java/​org/​keycloak/​gh/​bot/​AddAreaLabelToBugsTest.java Tests label application and existing-kind handling.
src/​test/​java/​org/​keycloak/​gh/​bot/​utils/​IssueParserTest.java Tests template detection and unmatched bodies.
src/​test/​resources/​org/​keycloak/​gh/​bot/​utils/​issue-body-bug-v2 Current bug-template fixture.
src/​test/​resources/​org/​keycloak/​gh/​bot/​utils/​issue-body-enhancement Legacy enhancement-template fixture.
src/​test/​resources/​org/​keycloak/​gh/​bot/​utils/​issue-body-enhancement-v2 Current enhancement-template fixture.
src/​test/​resources/​org/​keycloak/​gh/​bot/​utils/​issue-body-feature-v2 Current feature-template fixture.
src/​test/​resources/​org/​keycloak/​gh/​bot/​utils/​issue-body-plain Non-template fixture.
src/​test/​resources/​org/​keycloak/​gh/​bot/​utils/​issue-body-task-v2 Current task-template fixture.

Review effort: Balanced

Copilot AI left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Handler tests do not cover FEATURE and TASK label application, leaving the expected feature labels and task-only labeling behavior unverified.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment on lines +40 to +44
case FEATURE -> {
Labels.addLabelIfExists(issue, Labels.KIND_FEATURE);
Labels.addLabelIfExists(issue, Labels.STATUS_TRIAGE);
}
case TASK -> Labels.addLabelIfExists(issue, Labels.KIND_TASK);
@stianst stianst left a comment
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM except the class AddAreaLabelToBugs needs to be renamed to better reflect what it now does

ahus1 and others added 2 commits December 1, 2026 12:07
Closes keycloak#84

Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
The handler now also adds kind and triage labels, not only the area label.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
@ahus1
ahus1 force-pushed the is-84-detect-kind-from-body branch from 89c7da8 to 1cbd10d Compare December 1, 2026 11:07
@ahus1
ahus1 requested a review from stianst December 1, 2026 11:08
@stianst
stianst merged commit b5452f7 into keycloak:main Dec 1, 2026
2 checks passed
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.

Add labels for AI/API generated issues that don't have any labels

3 participants

0