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

fix: language plugins should always include an error with level=ERROR for BuildFailure #3296

Merged
merged 2 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions go-runtime/goplugin/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,8 @@ func build(ctx context.Context, projectRoot, stubsRoot string, buildCtx buildCon
m, buildErrs, err := compile.Build(ctx, projectRoot, stubsRoot, buildCtx.Config, buildCtx.Schema, transaction, false)
if err != nil {
return buildFailure(buildCtx, isAutomaticRebuild, builderrors.Error{
Type: builderrors.FTL,
Level: builderrors.ErrorLevel(builderrors.COMPILER),
Type: builderrors.COMPILER,
Level: builderrors.ERROR,
Msg: "compile: " + err.Error(),
}), nil
}
Expand Down
11 changes: 11 additions & 0 deletions internal/buildengine/languageplugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,17 @@ func buildResultFromProto(result either.Either[*langpb.BuildEvent_BuildSuccess,

errs := langpb.ErrorsFromProto(buildFailure.Errors)
builderrors.SortErrorsByPosition(errs)

if !builderrors.ContainsTerminalError(errs) {
// This happens if the language plugin returns BuildFailure but does not include any errors with level ERROR.
// Language plugins should always include at least one error with level ERROR in the case of a build failure.
errs = append(errs, builderrors.Error{
Msg: "unexpected build failure without error level ERROR",
Level: builderrors.ERROR,
Type: builderrors.FTL,
})
}

return BuildResult{
Errors: errs,
InvalidateDependencies: buildFailure.InvalidateDependencies,
Expand Down
Loading