Skip to content

Commit 2b4de1f

Browse files
Bruce Hillyjp20
authored andcommitted
Fix debug middleware getting applied overzealously
1 parent 0d26aa0 commit 2b4de1f

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

pkg/cmd/buildtargetoutput.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,14 @@ func handleBuildsTargetOutputsRetrieve(ctx context.Context, cmd *cli.Command) er
111111
Type: stainless.BuildTargetOutputGetParamsType(outputType),
112112
Output: stainless.BuildTargetOutputGetParamsOutput(outputFormat),
113113
}
114+
options := []option.RequestOption{}
115+
if cmd.Bool("debug") {
116+
options = append(options, debugMiddlewareOption)
117+
}
114118
res, err := client.Builds.TargetOutputs.Get(
115119
ctx,
116120
params,
117-
debugMiddlewareOption,
121+
options...,
118122
)
119123
if err != nil {
120124
return fmt.Errorf("failed to get output for target %s: %v", target, err)

pkg/cmd/dev.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/stainless-api/stainless-api-cli/pkg/components/dev"
2020
"github.com/stainless-api/stainless-api-cli/pkg/console"
2121
"github.com/stainless-api/stainless-api-go"
22+
"github.com/stainless-api/stainless-api-go/option"
2223
"github.com/stainless-api/stainless-api-go/shared"
2324
"github.com/tidwall/gjson"
2425
"github.com/urfave/cli/v3"
@@ -243,10 +244,14 @@ func runDevBuild(ctx context.Context, client stainless.Client, wc WorkspaceConfi
243244
ctx,
244245
branch,
245246
func() (*stainless.Build, error) {
247+
options := []option.RequestOption{}
248+
if cmd.Bool("debug") {
249+
options = append(options, debugMiddlewareOption)
250+
}
246251
build, err := client.Builds.New(
247252
ctx,
248253
buildReq,
249-
debugMiddlewareOption,
254+
options...,
250255
)
251256
if err != nil {
252257
return nil, fmt.Errorf("failed to create build: %v", err)
@@ -344,13 +349,17 @@ func getDiagnostics(ctx context.Context, cmd *cli.Command, client stainless.Clie
344349
}
345350
specParams.Source.OpenAPISpec = string(openAPISpec)
346351

352+
options := []option.RequestOption{}
353+
if cmd.Bool("debug") {
354+
options = append(options, debugMiddlewareOption)
355+
}
347356
var result []byte
348357
err = client.Post(
349358
ctx,
350359
"api/generate/spec",
351360
specParams,
352361
&result,
353-
debugMiddlewareOption,
362+
options...,
354363
)
355364
if err != nil {
356365
return nil, err

pkg/cmd/init.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
cbuild "github.com/stainless-api/stainless-api-cli/pkg/components/build"
1717
"github.com/stainless-api/stainless-api-cli/pkg/console"
1818
"github.com/stainless-api/stainless-api-cli/pkg/stainlessutils"
19+
"github.com/stainless-api/stainless-api-go/option"
1920

2021
tea "github.com/charmbracelet/bubbletea"
2122
"github.com/charmbracelet/huh"
@@ -333,11 +334,15 @@ func askCreateProject(ctx context.Context, cmd *cli.Command, client stainless.Cl
333334
},
334335
}
335336

337+
options := []option.RequestOption{}
338+
if cmd.Bool("debug") {
339+
options = append(options, debugMiddlewareOption)
340+
}
336341
err = group.Spinner("Creating project...", func() error {
337342
_, err = client.Projects.New(
338343
ctx,
339344
params,
340-
debugMiddlewareOption,
345+
options...,
341346
)
342347
return err
343348
})

0 commit comments

Comments
 (0)