Repository: prometheus/alertmanager
File: config/notifiers.go (Go)

Code before:
	APIURL  *URL   `yaml:"api_url,omitempty" json:"api_url,omitempty"`
	APIType string `yaml:"api_type,omitempty" json:"api_type,omitempty"`

	Project     string          `yaml:"project,omitempty" json:"project,omitempty"`
	Summary     JiraFieldConfig `yaml:"summary,omitempty" json:"summary,omitempty"`
	Description JiraFieldConfig `yaml:"description,omitempty" json:"description,omitempty"`
	Labels      []string        `yaml:"labels,omitempty" json:"labels,omitempty"`
	Priority    string          `yaml:"priority,omitempty" json:"priority,omitempty"`
	IssueType   string          `yaml:"issue_type,omitempty" json:"issue_type,omitempty"`

	ReopenTransition  string         `yaml:"reopen_transition,omitempty" json:"reopen_transition,omitempty"`
	ResolveTransition string         `yaml:"resolve_transition,omitempty" json:"resolve_transition,omitempty"`
	WontFixResolution string         `yaml:"wont_fix_resolution,omitempty" json:"wont_fix_resolution,omitempty"`
	ReopenDuration    model.Duration `yaml:"reopen_duration,omitempty" json:"reopen_duration,omitempty"`

	Fields map[string]any `yaml:"fields,omitempty" json:"custom_fields,omitempty"`
}

// Supports both the legacy string and the new object form.
func (f *JiraFieldConfig) UnmarshalYAML(unmarshal func(any) error) error {
	// Try simple string first (backward compatibility).
	var s string
	if err := unmarshal(&s); err == nil {
		f.Template = s
		// DisableUpdate stays false by default.
		return nil
	}

	// Fallback to full object form.
	type plain JiraFieldConfig
	var cfg plain
	if err := unmarshal(&cfg); err != nil {
		return err
	}

	*f = JiraFieldConfig(cfg)
	return nil
}

func (c *JiraConfig) UnmarshalYAML(unmarshal func(any) error) error {
	*c = DefaultJiraConfig
	type plain JiraConfig
	if err := unmarshal((*plain)(c)); err != nil {
		return err
	}

	if c.Project == "" {
		return errors.New("missing project in jira_config")
	}
	if c.IssueType == "" {
		return errors.New("missing issue_type in jira_config")

Review comment (suggestion):
This looks great! The documentation in `docs/configuration.md` should be updated to reflect this new behavior. 

Code after:
	APIURL  *URL   `yaml:"api_url,omitempty" json:"api_url,omitempty"`
	APIType string `yaml:"api_type,omitempty" json:"api_type,omitempty"`

	Project     string          `yaml:"project,omitempty" json:"project,omitempty"`
	Summary     JiraFieldConfig `yaml:"summary,omitempty" json:"summary,omitempty"`
	Description JiraFieldConfig `yaml:"description,omitempty" json:"description,omitempty"`
	Labels      []string        `yaml:"labels,omitempty" json:"labels,omitempty"`
	Priority    string          `yaml:"priority,omitempty" json:"priority,omitempty"`
	IssueType   string          `yaml:"issue_type,omitempty" json:"issue_type,omitempty"`

	ReopenTransition  string         `yaml:"reopen_transition,omitempty" json:"reopen_transition,omitempty"`
	ResolveTransition string         `yaml:"resolve_transition,omitempty" json:"resolve_transition,omitempty"`
	WontFixResolution string         `yaml:"wont_fix_resolution,omitempty" json:"wont_fix_resolution,omitempty"`
	ReopenDuration    model.Duration `yaml:"reopen_duration,omitempty" json:"reopen_duration,omitempty"`

	Fields map[string]any `yaml:"fields,omitempty" json:"custom_fields,omitempty"`
}

func (f *JiraFieldConfig) EnableUpdateValue() bool {
	if f.EnableUpdate == nil {
		return true
	}
	return *f.EnableUpdate
}

// Supports both the legacy string and the new object form.
func (f *JiraFieldConfig) UnmarshalYAML(unmarshal func(any) error) error {
	// Try simple string first (backward compatibility).
	var s string
	if err := unmarshal(&s); err == nil {
		f.Template = s
		// DisableUpdate stays false by default.
		return nil
	}

	// Fallback to full object form.
	type plain JiraFieldConfig
	return unmarshal((*plain)(f))
}

func (c *JiraConfig) UnmarshalYAML(unmarshal func(any) error) error {
	*c = DefaultJiraConfig
	type plain JiraConfig
	if err := unmarshal((*plain)(c)); err != nil {
		return err
	}

	if c.Project == "" {
		return errors.New("missing project in jira_config")
	}
	if c.IssueType == "" {