Skip to content
Merged
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
6 changes: 4 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"fmt"
"log/slog"
"maps"
"net/url"
"slices"
"strings"
Expand Down Expand Up @@ -73,9 +74,10 @@ func CheckRequiredEnvVars(ctx context.Context, cfg *latest.Config, modelsGateway
}

func parseCurrentVersion(data []byte, version string) (any, error) {
parser, found := Parsers()[version]
parsers := Parsers()
parser, found := parsers[version]
if !found {
return nil, fmt.Errorf("unsupported config version: %v", version)
return nil, fmt.Errorf("unsupported config version: %v (valid versions: %s)", version, strings.Join(slices.Sorted(maps.Keys(parsers)), ", "))
}
return parser(data)
}
Expand Down
18 changes: 18 additions & 0 deletions pkg/config/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -71,6 +72,23 @@ func TestValidationErrors(t *testing.T) {
}
}

func TestLoadConfig_UnsupportedVersion(t *testing.T) {
t.Parallel()

cfg := `version: "99"
agents:
root:
model: openai/gpt-4
`
_, err := Load(t.Context(), NewBytesSource("test", []byte(cfg)))
require.Error(t, err)
assert.Contains(t, err.Error(), "unsupported config version: 99")
assert.Contains(t, err.Error(), "valid versions")
// Check that at least some known versions are listed
assert.Contains(t, err.Error(), "1")
assert.Contains(t, err.Error(), "2")
}

func TestValidSkillsConfiguration(t *testing.T) {
t.Parallel()

Expand Down