Skip to content

README,cmd/issuebot,go.{sum,mod}: update issuebot to support Jira keys - #4

Open
mikeodr wants to merge 1 commit into
mainfrom
mikeodr/add-jira-support
Open

mikeodr wants to merge 1 commit into
mainfrom
mikeodr/add-jira-support

Conversation

@mikeodr

@mikeodr mikeodr commented Sep 22, 2026

Copy link
Copy Markdown
  • Add support for known jira keys for issue link detection
  • Update dependencies
  • Use go fix to modernize

- Add support for known jira keys for issue link detection
- Update dependencies
- Use `go fix` to modernize
@mikeodr

mikeodr commented Sep 22, 2026

Copy link
Copy Markdown
Author

I can apparently merge without a review, but will wait for approvals.

Comment thread cmd/issuebot/issuebot.go
// key. If key is too long for the description to fit the GitHub limit, a
// generic placeholder is used instead.
func jiraMissingCommitDescription(key string) string {
if s := fmt.Sprintf(missingCommitExplanationJira, key); len(s) <= maxStatusDescriptionLen {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems like overkill, if we're going to fall back to "KEY" anyway, we should probably just do that. (Listing out all the available options that might be worthwhile, but for a single example this seems excessive)

Comment thread cmd/issuebot/issuebot.go
// handling: "[EDGE-12]" matches on the word boundary. The keys must already
// have been validated by parseJiraProjectKeys.
func compileJiraKeyRE(keys []string) *regexp.Regexp {
return regexp.MustCompile(`\b(?:` + strings.Join(keys, "|") + `)-\d+\b`)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For extra paranoia, we should probably regexp.QuoteMeta each of them.

Comment thread cmd/issuebot/issuebot.go
// Requiring an explicit allowlist keeps a bare "PROJ-123" shape from matching
// incidental text like "Fixes UTF-8 handling" or "Fixes RFC-2119".
func parseJiraProjectKeys(spec string) ([]string, error) {
var keys []string

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I recommend

Suggested change
var keys []string
if spec == "" {
return nil, nil
}
var keys []string

and then reject an empty string below. Rationale: Other than "" itself, the only way we get an empty string is if someone mangles the flag value, and that should probably be an error rather than a silent skip.

Comment thread cmd/issuebot/issuebot.go
}

// jiraProjectKeyRE matches a well-formed Jira project key.
var jiraProjectKeyRE = regexp.MustCompile(`^[A-Za-z][A-Za-z0-9]*$`)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we want to allow lowercase? It seems like the lexical convention is ALL UPPER.

Comment thread cmd/issuebot/issuebot.go
// plausible Jira project key (letters and digits, starting with a letter).
// Requiring an explicit allowlist keeps a bare "PROJ-123" shape from matching
// incidental text like "Fixes UTF-8 handling" or "Fixes RFC-2119".
func parseJiraProjectKeys(spec string) ([]string, error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Consider maybe folding the parse and compile together?

func parseJiraProjectKeys(spec string) (*regexp.Regexp, error) {

since the caller is just going to compile them anyway, and nil means skip.

}

func TestParseJiraProjectKeys(t *testing.T) {
t.Run("Empty", func(t *testing.T) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should reject this entirely.

@bradfitz bradfitz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Haven't we rejected this in the past? What changed?

This is a policy change, not a technical change.

@bradfitz

Copy link
Copy Markdown
Member

(also: typo in issubot)

@mikeodr mikeodr changed the title README,cmd/issubot,go.{sum,mod}: update issuebot to support Jira keys README,cmd/issuebot,go.{sum,mod}: update issuebot to support Jira keys Sep 22, 2026
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.

3 participants