Skip to content
Draft
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
30 changes: 30 additions & 0 deletions cmd/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package cmd

import (
"context"
"errors"
"reflect"
"strings"
"testing"

"github.com/kong/go-database-reconciler/pkg/crud"
"github.com/kong/go-database-reconciler/pkg/diff"
"github.com/kong/go-database-reconciler/pkg/dump"
"github.com/kong/go-database-reconciler/pkg/file"
Expand Down Expand Up @@ -281,3 +284,30 @@ func TestIsAIGatewayInstance(t *testing.T) {
})
}
}

// TestSyncErrorMessage_UnnamedRoute reproduces the reported bug: a sync
// failure on a route that has no `name` in the source YAML used to be
// reported only by its Kong-assigned ID, which doesn't appear anywhere in
// the source file and so can't be correlated back to it without a separate
// `deck dump --with-id`. It should now be identified by paths/methods/hosts
// and its parent service instead.
func TestSyncErrorMessage_UnnamedRoute(t *testing.T) {
var route state.Route
route.ID = kong.String("018e1c1e-71cd-7c53-8000-000000000001")
route.Paths = kong.StringSlice("/foo", "/bar")
route.Methods = kong.StringSlice("GET")
route.Service = &kong.Service{Name: kong.String("my-service")}

actionErr := &crud.ActionError{
OperationType: crud.Update,
Kind: "route",
Name: route.Console(),
Err: errors.New("db error"),
}

msg := actionErr.Error()
assert.NotContains(t, msg, "018e1c1e-71cd-7c53-8000-000000000001",
"error message should not require a --with-id dump to correlate back to source YAML")
assert.True(t, strings.Contains(msg, "/foo") && strings.Contains(msg, "/bar") && strings.Contains(msg, "my-service"),
"error message should identify the route by its paths and service: %q", msg)
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/fatih/color v1.19.0
github.com/google/go-cmp v0.7.0
github.com/kong/go-apiops v0.4.6
github.com/kong/go-database-reconciler v1.42.4
github.com/kong/go-database-reconciler v1.42.5-0.20260923145110-14087d93471f
github.com/kong/go-kong v0.78.0
github.com/mitchellh/go-homedir v1.1.0
github.com/spf13/cobra v1.10.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kong/go-apiops v0.4.6 h1:sQkTievX92AT5PZNZcUFbm7inysBVeZIIagXN8MWnP8=
github.com/kong/go-apiops v0.4.6/go.mod h1:Xt99d90LallLVwYJAGaufiNbBdsK0KKboe7gR4Ryths=
github.com/kong/go-database-reconciler v1.42.4 h1:CxeipG/dWIHi73bztg6BU7lIwotOKP1FUmfbz7sp6PE=
github.com/kong/go-database-reconciler v1.42.4/go.mod h1:/lEPLhpDI1x+OOhQ+JeY3OsxvXYN04o12AmqzN7llRQ=
github.com/kong/go-database-reconciler v1.42.5-0.20260923145110-14087d93471f h1:hIS1tZ/QRI/b/sxOjev57clmUXukPrXNRd2v1ejDUoQ=
github.com/kong/go-database-reconciler v1.42.5-0.20260923145110-14087d93471f/go.mod h1:w6z3RdkKvDPQaehhhuPA41E3k5tHRX1Cfk+o6hn+JCI=
github.com/kong/go-kong v0.78.0 h1:VK5g26BCeF+l9o3j3pgU3BOuOdmTd9Vj33x29mKGtkg=
github.com/kong/go-kong v0.78.0/go.mod h1:Wx5aTcMjyUnIF94M5NYFWb/EnuEkqB5STrWvybFSYYQ=
github.com/kong/go-slugify v1.0.0 h1:vCFAyf2sdoSlBtLcrmDWUFn0ohlpKiKvQfXZkO5vSKY=
Expand Down
Loading