Skip to content

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

Open
ahus1 wants to merge 1 commit into
keycloak:mainfrom
ahus1:is-84-detect-kind-from-body
Open

ahus1 wants to merge 1 commit 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
@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

Closes keycloak#84

Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
@ahus1
ahus1 force-pushed the is-84-detect-kind-from-body branch from 3d38751 to e030191 Compare November 13, 2026 15:29
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