Skip to content

Panic error on config parsing when update_message: true in slack_configs #5164

@hzieba

Description

@hzieba

What did you do?

Hi team,
I'm trying to enable #5007, but Alertmanager fails to parse config file whenever I specify update_message: true (see broken config and logs in attachement).

When update_message: false or I set api_url for each notifier, Alertmanager is able to parse the config.

# amconfig_good.yaml
global:
  slack_api_url: "https://slack.com/api/chat.postMessage"
route:
  receiver: foo
receivers:
  - name: foo
    slack_configs:
      - channel: bar-channel
        send_resolved: true
        update_message: true
        api_url: "https://slack.com/api/chat.postMessage"
      - channel: bar-channel
        send_resolved: true
        update_message: false
$ amtool check-config amconfig_good.yaml
Checking 'amconfig_good.yaml'  SUCCESS
Found:
 - global config
 - route
 - 0 inhibit rules
 - 1 receivers
 - 0 templates

What did you expect to see?

Validation should respect global.slack_api_url config or throw error in human-readable format

What did you see instead? Under which circumstances?

Fatal error during config unmarshaling

System information

Darwin 25.4.0 arm64

Alertmanager version

version: 0.32.0
branch: main
revision: bf98d8214337743a22f2eb7b35980f15ba745829

`amtool` doesn't report version correctly when installed with `go install github.com/prometheus/alertmanager/cmd/[email protected]`

$ amtool --version
amtool, version  (branch: , revision: unknown)
  build user:
  build date:
  go version:       go1.26.2
  platform:         darwin/arm64
  tags:             unknown

Alertmanager configuration file

# amconfig_bad.yaml
global:
  slack_api_url: "https://slack.com/api/chat.postMessage"
route:
  receiver: foo
receivers:
  - name: foo
    slack_configs:
      - channel: bar-channel
        send_resolved: true
        update_message: true

Prometheus version

Not relevant

Prometheus configuration file

Not relevant

Logs

$ amtool check-config amconfig_bad.yaml
Checking 'amconfig.yaml'panic: runtime error: invalid memory address or nil pointer dereference [recovered, repanicked]
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x104cb7018]

goroutine 1 [running]:
gopkg.in/yaml%2ev2.handleErr(0x10242137f9d8)
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/yaml.go:249 +0x6c
panic({0x1055e1780?, 0x1057e39c0?})
	/opt/homebrew/Cellar/go/1.26.2/libexec/src/runtime/panic.go:860 +0x12c
gopkg.in/yaml%2ev2.handleErr(0x10242137ecd0)
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/yaml.go:249 +0x6c
panic({0x1055e1780?, 0x1057e39c0?})
	/opt/homebrew/Cellar/go/1.26.2/libexec/src/runtime/panic.go:860 +0x12c
gopkg.in/yaml%2ev2.handleErr(0x10242137e5b0)
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/yaml.go:249 +0x6c
panic({0x1055e1780?, 0x1057e39c0?})
	/opt/homebrew/Cellar/go/1.26.2/libexec/src/runtime/panic.go:860 +0x12c
github.com/prometheus/alertmanager/config.(*SlackConfig).UnmarshalYAML(0x102421452380, 0x107d94a70?)
	/Users/hzieba/go/pkg/mod/github.com/prometheus/[email protected]/config/notifiers.go:585 +0x188
gopkg.in/yaml%2ev2.(*decoder).callUnmarshaler(0x102421136de0, 0x10242142a7e0, {0x107d94a70, 0x102421452380})
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/decode.go:270 +0x90
gopkg.in/yaml%2ev2.(*decoder).prepare(0x102421136de0, 0x10242142a7e0, {0x1055e8640?, 0x1024210e2738?, 0x10242137e058?})
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/decode.go:313 +0x25c
gopkg.in/yaml%2ev2.(*decoder).unmarshal(0x102421136de0, 0x10242142a7e0, {0x1055e8640?, 0x1024210e2738?, 0x1024210f2d80?})
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/decode.go:364 +0x180
gopkg.in/yaml%2ev2.(*decoder).sequence(0x102421136de0, 0x10242142a770, {0x10556b760?, 0x102421452230?, 0x10242137e198?})
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/decode.go:609 +0x2a0
gopkg.in/yaml%2ev2.(*decoder).unmarshal(0x102421136de0, 0x10242142a770, {0x10556b760?, 0x102421452230?, 0x19?})
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/decode.go:374 +0x1d8
gopkg.in/yaml%2ev2.(*decoder).mappingStruct(0x102421136de0, 0x10242142a5b0, {0x105708960?, 0x1024214521c0?, 0x105554b00?})
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/decode.go:767 +0x9e4
gopkg.in/yaml%2ev2.(*decoder).mapping(0x102421136de0?, 0x10242142a5b0?, {0x105708960?, 0x1024214521c0?, 0x10242137e548?})
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/decode.go:626 +0x384
gopkg.in/yaml%2ev2.(*decoder).unmarshal(0x102421136de0, 0x10242142a5b0, {0x105554b00?, 0x1024214521c0?, 0x10?})
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/decode.go:372 +0x1f4
gopkg.in/yaml%2ev2.(*decoder).callUnmarshaler.func1({0x105554b00?, 0x1024214521c0?})
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/decode.go:272 +0xc4
github.com/prometheus/alertmanager/config.(*Receiver).UnmarshalYAML(0x1024214521c0, 0x107d94a50?)
	/Users/hzieba/go/pkg/mod/github.com/prometheus/[email protected]/config/config.go:952 +0x34
gopkg.in/yaml%2ev2.(*decoder).callUnmarshaler(0x102421136de0, 0x10242142a5b0, {0x107d94a50, 0x1024214521c0})
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/decode.go:270 +0x90
gopkg.in/yaml%2ev2.(*decoder).prepare(0x102421136de0, 0x10242142a5b0, {0x1057084e0?, 0x1024214521c0?, 0x10242137e778?})
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/decode.go:313 +0x25c
gopkg.in/yaml%2ev2.(*decoder).unmarshal(0x102421136de0, 0x10242142a5b0, {0x1057084e0?, 0x1024214521c0?, 0x1024210f2d50?})
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/decode.go:364 +0x180
gopkg.in/yaml%2ev2.(*decoder).sequence(0x102421136de0, 0x10242142a540, {0x10556bc20?, 0x1024214371f8?, 0x10242137e8b8?})
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/decode.go:609 +0x2a0
gopkg.in/yaml%2ev2.(*decoder).unmarshal(0x102421136de0, 0x10242142a540, {0x10556bc20?, 0x1024214371f8?, 0x10566ab60?})
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/decode.go:374 +0x1d8
gopkg.in/yaml%2ev2.(*decoder).mappingStruct(0x102421136de0, 0x10242142a0e0, {0x1056de4c0?, 0x1024214371d0?, 0x105554a40?})
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/decode.go:767 +0x9e4
gopkg.in/yaml%2ev2.(*decoder).mapping(0x102421136de0?, 0x10242142a0e0?, {0x1056de4c0?, 0x1024214371d0?, 0x10242137ec68?})
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/decode.go:626 +0x384
gopkg.in/yaml%2ev2.(*decoder).unmarshal(0x102421136de0, 0x10242142a0e0, {0x105554a40?, 0x1024214371d0?, 0x10242137ecb8?})
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/decode.go:372 +0x1f4
gopkg.in/yaml%2ev2.(*decoder).callUnmarshaler.func1({0x105554a40?, 0x1024214371d0?})
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/decode.go:272 +0xc4
github.com/prometheus/alertmanager/config.(*Config).UnmarshalYAML(0x1024214371d0, 0x107d949b0?)
	/Users/hzieba/go/pkg/mod/github.com/prometheus/[email protected]/config/config.go:289 +0x3c
gopkg.in/yaml%2ev2.(*decoder).callUnmarshaler(0x102421136de0, 0x10242142a0e0, {0x107d949b0, 0x1024214371d0})
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/decode.go:270 +0x90
gopkg.in/yaml%2ev2.(*decoder).prepare(0x102421136de0, 0x10242142a0e0, {0x1056e2c40?, 0x1024214371d0?, 0x10555a500?})
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/decode.go:313 +0x25c
gopkg.in/yaml%2ev2.(*decoder).unmarshal(0x102421136de0, 0x10242142a0e0, {0x1056e2c40?, 0x1024214371d0?, 0x10242137f978?})
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/decode.go:364 +0x180
gopkg.in/yaml%2ev2.(*decoder).document(...)
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/decode.go:384
gopkg.in/yaml%2ev2.(*decoder).unmarshal(0x102421136de0, 0x10242142a070, {0x1056e2c40?, 0x1024214371d0?, 0x10242137f9f8?})
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/decode.go:360 +0x15c
gopkg.in/yaml%2ev2.unmarshal({0x1024214400e0, 0xdb, 0xe0}, {0x1055e83c0, 0x1024214371d0}, 0x1)
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/yaml.go:148 +0x2ec
gopkg.in/yaml%2ev2.UnmarshalStrict(...)
	/Users/hzieba/go/pkg/mod/gopkg.in/[email protected]/yaml.go:89
github.com/prometheus/alertmanager/config.Load({0x102421440000, 0xdb})
	/Users/hzieba/go/pkg/mod/github.com/prometheus/[email protected]/config/config.go:120 +0x54
github.com/prometheus/alertmanager/config.LoadFile({0x16b7cb08c, 0xd})
	/Users/hzieba/go/pkg/mod/github.com/prometheus/[email protected]/config/config.go:146 +0x3c
github.com/prometheus/alertmanager/cli.CheckConfig({0x102421438290?, 0x10242137fb48?, 0x10242137fc68?})
	/Users/hzieba/go/pkg/mod/github.com/prometheus/[email protected]/cli/check_config.go:67 +0x188
github.com/prometheus/alertmanager/cli.(*checkConfigCmd).checkConfig(...)
	/Users/hzieba/go/pkg/mod/github.com/prometheus/[email protected]/cli/check_config.go:48
github.com/alecthomas/kingpin/v2.(*actionMixin).applyActions(...)
	/Users/hzieba/go/pkg/mod/github.com/alecthomas/kingpin/[email protected]/actions.go:28
github.com/alecthomas/kingpin/v2.(*Application).applyActions(0x102421428100?, 0x1024211a8750)
	/Users/hzieba/go/pkg/mod/github.com/alecthomas/kingpin/[email protected]/app.go:568 +0xe4
github.com/alecthomas/kingpin/v2.(*Application).execute(0x102421428100, 0x1024211a8750, {0x102421438260, 0x1, 0x1})
	/Users/hzieba/go/pkg/mod/github.com/alecthomas/kingpin/[email protected]/app.go:398 +0x50
github.com/alecthomas/kingpin/v2.(*Application).Parse(0x102421428100, {0x1024212b0280?, 0x1024212b0280?, 0x102421419260?})
	/Users/hzieba/go/pkg/mod/github.com/alecthomas/kingpin/[email protected]/app.go:230 +0xe8
github.com/prometheus/alertmanager/cli.Execute()
	/Users/hzieba/go/pkg/mod/github.com/prometheus/[email protected]/cli/root.go:184 +0xff8
main.main()
	/Users/hzieba/go/pkg/mod/github.com/prometheus/[email protected]/cmd/amtool/main.go:19 +0x1c

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    In progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions