From f0d119923a3ab3d059ca2f2ed3de7ccbb1639bed Mon Sep 17 00:00:00 2001 From: Lindsey B Date: Wed, 6 May 2026 11:52:32 -0700 Subject: [PATCH] fix(REL-13522): convert kebab-case query params to camelCase --- cmd/resources/resource_cmds_test.go | 28 ++++++++++++++++++++++++++++ cmd/resources/resources.go | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/cmd/resources/resource_cmds_test.go b/cmd/resources/resource_cmds_test.go index 8bc95379..b98fba70 100644 --- a/cmd/resources/resource_cmds_test.go +++ b/cmd/resources/resource_cmds_test.go @@ -8,8 +8,36 @@ import ( "github.com/launchdarkly/ldcli/cmd" "github.com/launchdarkly/ldcli/internal/analytics" + "github.com/launchdarkly/ldcli/internal/resources" ) +func TestKebabCaseQueryParamConversion(t *testing.T) { + mockClient := &resources.MockClient{ + Response: []byte(`{"items": []}`), + } + + t.Run("converts kebab-case flag --with-branches to camelCase query param withBranches", func(t *testing.T) { + args := []string{ + "code-refs", "list-repositories", + "--access-token", "abcd1234", + "--with-branches", "true", + } + + _, err := cmd.CallCmd( + t, + cmd.APIClients{ + ResourcesClient: mockClient, + }, + analytics.NoopClientFn{}.Tracker(), + args, + ) + + require.NoError(t, err) + assert.Equal(t, "true", mockClient.Query.Get("withBranches"), "query param should be camelCase withBranches, not kebab-case with-branches") + assert.Empty(t, mockClient.Query.Get("with-branches"), "kebab-case with-branches should not appear in query") + }) +} + func TestCreateTeam(t *testing.T) { t.Run("help shows postTeam description", func(t *testing.T) { args := []string{ diff --git a/cmd/resources/resources.go b/cmd/resources/resources.go index 31ae3167..188204e1 100644 --- a/cmd/resources/resources.go +++ b/cmd/resources/resources.go @@ -318,7 +318,7 @@ func (op *OperationCmd) makeRequest(cmd *cobra.Command, args []string) error { case "path": urlParms = append(urlParms, val) case "query": - query.Add(p.Name, val) + query.Add(strcase.ToLowerCamel(p.Name), val) } } }