Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
- `server`: Support HTTP request/response MCP with the `--mcp-enabled` and `--mcp-path` flags.
- MCP: Add the `context`, `list_slos` and `get_slo` tools.

### Fixed

- `server --prometheus-header` no longer panics with "assignment to entry in nil map".

## [v0.16.0] - 2026-04-04

### Added
Expand Down
1 change: 1 addition & 0 deletions cmd/sloth/commands/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type serverCommand struct {
// NewServerCommand returns the UI command.
func NewServerCommand(app *kingpin.Application) Command {
c := &serverCommand{}
c.prometheus.headers = map[string]string{}
cmd := app.Command("server", "Starts the Sloth web server.")
cmd.Flag("app-listen-address", "Application listen address.").Default(":8080").StringVar(&c.appServer.address)
cmd.Flag("status-listen-address", "Status (health check, metrics, pprof...) listen address.").Default(":8081").StringVar(&c.statusServer.address)
Expand Down
24 changes: 24 additions & 0 deletions cmd/sloth/commands/server_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package commands_test

import (
"testing"

"github.com/alecthomas/kingpin/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/slok/sloth/cmd/sloth/commands"
)

// TestServerCommandPrometheusHeaderFlag checks that the `server --prometheus-header`
// flag can be parsed without panicking. Regression test for the nil map panic
// ("assignment to entry in nil map") reported when the backing map was not
// initialized before being used by kingpin's StringMap value.
func TestServerCommandPrometheusHeaderFlag(t *testing.T) {
app := kingpin.New("sloth", "test")
commands.NewServerCommand(app)

cmd, err := app.Parse([]string{"server", "--prometheus-header=Some-Header=Value"})
require.NoError(t, err)
assert.Equal(t, "server", cmd)
}
Loading