Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

launch: better incomplete manifest visibility #3659

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 5 additions & 2 deletions internal/command/launch/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ func run(ctx context.Context) (err error) {
if err != nil {
tracing.RecordError(span, err, "launch failed")
status.Error = err.Error()
if info := flyerr.GetErrorDebugInfo(err); info != "" {
status.Error += "\n" + info
}

if state != nil && state.sourceInfo != nil && state.sourceInfo.FailureCallback != nil {
err = state.sourceInfo.FailureCallback(err)
Expand Down Expand Up @@ -288,7 +291,7 @@ func run(ctx context.Context) (err error) {
summary,
)

if errors := recoverableErrors.build(); errors != "" {
if errors := recoverableErrors.buildDisplayableErrorList(); errors != "" {

fmt.Fprintf(io.ErrOut, "\n%s\n%s\n", aurora.Reverse(aurora.Red("The following problems must be fixed in the Launch UI:")), errors)
incompleteLaunchManifest = true
Expand All @@ -314,7 +317,7 @@ func run(ctx context.Context) (err error) {
}
} else if incompleteLaunchManifest {
// UI was required to reconcile launch issues, but user denied. Abort.
return errors.New("launch can not continue with errors present")
return recoverableErrors.toError()
}

err = state.Launch(ctx)
Expand Down
23 changes: 22 additions & 1 deletion internal/command/launch/plan_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (r *recoverableErrorBuilder) tryRecover(e error) error {
return e
}

func (r *recoverableErrorBuilder) build() string {
func (r *recoverableErrorBuilder) buildDisplayableErrorList() string {
if len(r.errors) == 0 {
return ""
}
Expand All @@ -100,6 +100,27 @@ func (r *recoverableErrorBuilder) build() string {
return allErrors
}

func (r *recoverableErrorBuilder) toError() error {
if len(r.errors) == 0 {
return nil
}
return IncompleteManifestError{
debug: r.buildDisplayableErrorList(),
}
}

type IncompleteManifestError struct {
debug string
}

func (e IncompleteManifestError) Error() string {
return "launch can not continue with errors present"
}

func (e IncompleteManifestError) DebugInfo() string {
return e.debug
}

func buildManifest(ctx context.Context, recoverableErrors *recoverableErrorBuilder) (*LaunchManifest, *planBuildCache, error) {
io := iostreams.FromContext(ctx)

Expand Down
14 changes: 14 additions & 0 deletions internal/flyerr/flyerr.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,17 @@ func IsCancelledError(err error) bool {

return false
}

// ErrorDebugInfo is an error with debug information that should be attached to metrics, logs, or sent to Sentry
type ErrorDebugInfo interface {
error
DebugInfo() string
}

func GetErrorDebugInfo(err error) string {
var ferr ErrorDebugInfo
if errors.As(err, &ferr) {
return ferr.DebugInfo()
}
return ""
}
Loading