Skip to content

Commit 91eea56

Browse files
authored
Merge pull request #1963 from buildkite/pdp-566-exit-early-when-a-pipeline-contains
2 parents c7abbce + 6952026 commit 91eea56

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: clicommand/pipeline_upload.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package clicommand
33
import (
44
"context"
55
"encoding/json"
6+
"errors"
67
"fmt"
78
"io"
89
"os"
@@ -248,8 +249,8 @@ var PipelineUploadCommand = cli.Command{
248249

249250
if len(cfg.RedactedVars) > 0 {
250251
needles := redaction.GetKeyValuesToRedact(shell.StderrLogger, cfg.RedactedVars, env.FromSlice(os.Environ()))
251-
serialisedPipeline, err := result.MarshalJSON()
252252

253+
serialisedPipeline, err := result.MarshalJSON()
253254
if err != nil {
254255
l.Fatal("Couldn’t scan the %q pipeline for redacted variables. This parsed pipeline could not be serialized, ensure the pipeline YAML is valid, or ignore interpolated secrets for this upload by passing --redacted-vars=''. (%s)", src, err)
255256
}
@@ -315,6 +316,13 @@ var PipelineUploadCommand = cli.Command{
315316
if err != nil {
316317
l.Warn("%s (%s)", err, r)
317318

319+
if jsonerr := new(json.MarshalerError); errors.As(err, &jsonerr) {
320+
l.Error("Unrecoverable error, skipping retries")
321+
r.Break()
322+
323+
return jsonerr
324+
}
325+
318326
// 422 responses will always fail no need to retry
319327
if apierr, ok := err.(*api.ErrorResponse); ok && apierr.Response.StatusCode == 422 {
320328
l.Error("Unrecoverable error, skipping retries")

0 commit comments

Comments
 (0)