Repository: prometheus/alertmanager
File: notify/jira/jira.go (Go)

Code before:
	}

	if existingIssue == nil {
		// Do not create new issues for resolved alerts
		if alerts.Status() == model.AlertResolved {
			return false, nil
		}

		logger.Debug("create new issue")
	} else {
		path = "issue/" + existingIssue.Key
		method = http.MethodPut

		msg := "updating existing issue"
		var disabled []string
		if n.conf.Summary.DisableUpdate {
			disabled = append(disabled, "summary")
		}
		if n.conf.Description.DisableUpdate {
			disabled = append(disabled, "description")
		}
		if len(disabled) > 0 {
			msg += " without " + strings.Join(disabled, " and ")
		}

		logger.Debug(msg, "issue_key", existingIssue.Key)
	}

	requestBody, err := n.prepareIssueRequestBody(ctx, logger, key.Hash(), tmplTextFunc)
	if err != nil {
		return false, err
	}

	if method == http.MethodPut && requestBody.Fields != nil {
		if n.conf.Description.DisableUpdate {
			requestBody.Fields.Description = nil
		}
		if n.conf.Summary.DisableUpdate {
			requestBody.Fields.Summary = nil
		}
	}

	_, shouldRetry, err = n.doAPIRequest(ctx, method, path, requestBody)
	if err != nil {
		return shouldRetry, fmt.Errorf("failed to %s request to %q: %w", method, path, err)
	}

	return n.transitionIssue(ctx, logger, existingIssue, alerts.HasFiring())
}

func (n *Notifier) prepareIssueRequestBody(_ context.Context, logger *slog.Logger, groupID string, tmplTextFunc template.TemplateFunc) (issue, error) {

Review comment (bug):
small nitpick: It's not very idiomatic to build a dynamic `msg` for structured logging. I'd rather see 
```suggestion
		logger.Debug(msg, "issue_key", existingIssue.Key, "disabled", disabled)
```
This makes things a little better for those who are indexing their logs. Example: https://go.dev/play/p/0dlLuNhdO8e

Code after:
	}

	if existingIssue == nil {
		// Do not create new issues for resolved alerts
		if alerts.Status() == model.AlertResolved {
			return false, nil
		}

		logger.Debug("create new issue")
	} else {
		path = "issue/" + existingIssue.Key
		method = http.MethodPut
		logger.Debug("updating existing issue", "issue_key", existingIssue.Key, "summary_update_enabled", n.conf.Summary.EnableUpdateValue(), "description_update_enabled", n.conf.Description.EnableUpdateValue())
	}

	requestBody, err := n.prepareIssueRequestBody(ctx, logger, key.Hash(), tmplTextFunc)
	if err != nil {
		return false, err
	}

	if method == http.MethodPut && requestBody.Fields != nil {
		if !n.conf.Description.EnableUpdateValue() {
			requestBody.Fields.Description = nil
		}
		if !n.conf.Summary.EnableUpdateValue() {
			requestBody.Fields.Summary = nil
		}
	}

	_, shouldRetry, err = n.doAPIRequest(ctx, method, path, requestBody)
	if err != nil {
		return shouldRetry, fmt.Errorf("failed to %s request to %q: %w", method, path, err)
	}

	return n.transitionIssue(ctx, logger, existingIssue, alerts.HasFiring())
}

func (n *Notifier) prepareIssueRequestBody(_ context.Context, logger *slog.Logger, groupID string, tmplTextFunc template.TemplateFunc) (issue, error) {
	summary, err := tmplTextFunc(n.conf.Summary.Template)
	if err != nil {
		return issue{}, fmt.Errorf("summary template: %w", err)
	}

	project, err := tmplTextFunc(n.conf.Project)
	if err != nil {
		return issue{}, fmt.Errorf("project template: %w", err)
	}
	issueType, err := tmplTextFunc(n.conf.IssueType)
	if err != nil {
		return issue{}, fmt.Errorf("issue_type template: %w", err)
	}