Skip to content

go: give the engine a function's error file - #113

Merged
vito merged 3 commits into
mainfrom
function-error-file
Nov 24, 2026
Merged

vito merged 3 commits into
mainfrom
function-error-file

Conversation

@vito

@vito vito commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Depends on dagger/dagger#15249, which adds the engine side: the module process's function error file, DAGGER_FUNCTION_ERROR_PATH.

When the engine sets that variable on the dispatcher's exec, the dispatcher writes the function's error there instead of printing it, as dagger/python-sdk#93 does for Python:

{"message": "<err.Error(), in full, [traceparent:…] kept>", "values": {<the inner GraphQL error's extensions, verbatim>}}
  • The engine fails the call with that error, values and all. A caller gets a typed ExecError with the inner exec's exit code, output and command. dagger call exits with the inner exit code.
  • The origin stays the failed inner call.
  • The dispatcher prints no error echo and no ::dagger-function-error:: or ::dagger-function-error-values:: lines, so the function's row shows only what the function itself logged.
  • The report is shortened only past the engine's 1 MiB read limit: the message keeps its start and its traceparents, and long strings keep their end.
  • Every dispatcher has this, whatever the module targets. The engine is detected at run time by the variable, so errorValuesFloor now only gates the old-engine fallback.

Falling back on older engines: without the variable, or when the file can't be written, the dispatcher prints the markers as before.

The generated entrypoint's raiseFunctionError raises the exec error unchanged when it carries the report the engine read (functionError). The engine's module-process handling then applies, and neither the marker parsing nor the values-marker Dagger.error() rebuild preempts it. Any other exec error still goes through the markers.

Tested:

  • Unit tests in templates/v2_test.go cover the file's contents, the 1 MiB cap, printing nothing else, the fallback when the file can't be written, and the entrypoint guard.
  • On core, idtui: readable errors from entrypoint SDK modules dagger#15249, pinning this branch makes every sdks-go-* golden match its target, except broken-default's placeholder breadcrumb, which is an engine/TUI question. The shared go-sdk dependency's rows are clean in every SDK's call-failing-dep goldens.
  • A new integration test, TestModuleEntrypointFunctionErrorGoSDK, checks that a caller gets a typed ExecError from a go-sdk function.

vito added 2 commits November 22, 2026 04:29
An engine that names a file for the function's error
(DAGGER_FUNCTION_ERROR_PATH, dagger/dagger#15249) now gets it there from
every dispatcher, whatever the module targets: {"message", "values"}, the
message in full with the origin it names, and the extensions of the GraphQL
error it wraps as they are, so a caller gets a typed ExecError with its exit
code and output. The dispatcher then prints nothing of its own; the report
is shortened only past the engine's 1 MiB limit. Without the variable, or a
file it can write, it falls back to the stderr markers older engines read.

The generated entrypoint raises a module process's exec error as it is, so
the engine's handling of it is never preempted by the marker parsing or the
Dagger Error rebuilt from the values marker.

Signed-off-by: Alex Suraci <[email protected]>
An engine that names a function error file marks the dispatcher's exec
error as the module process's even when the dispatcher couldn't write the
file and printed the marker lines instead; raising every such error as it
is made that fallback dead. The entrypoint now raises an exec error as it is
only when it carries the report the engine read (functionError), and parses
the markers otherwise.

Also say that passesErrorValues only matters to engines without the file,
and that the e2e error relay check passes through either path.

Signed-off-by: Alex Suraci <[email protected]>
vito added a commit to dagger/dagger that referenced this pull request Nov 22, 2026
Pin go-sdk to dagger/go-sdk#113 (5ed109c), whose dispatcher writes a
function's error to the engine's DAGGER_FUNCTION_ERROR_PATH and whose
entrypoint raises the exec error that carries it as it is, and regenerate
the go fixture and the shared dep, a go-sdk module.

Every sdks-go golden now renders as its target, fail-api included, except
broken-default: its "┇ build ›" breadcrumb is still a placeholder, and the
real one lists the entrypoint's dagger/go calls. Its compiler error moved to
./main.go:93:9 when fail-api grew the fixture.

The dep's rows are now clean in every SDK's call-failing-dep goldens, as the
targets have them, so the Python ones drop the rows relaxed for it: the
::dagger-function-error:: echo and the failed "call module entrypoint". The
dep's failure also reaches Python as an ExecError, values and all, so its
traceback ends in dagger.ExecError rather than dagger.QueryError.

Go's fail-exec-wrapped, which records today's output since wrapping isn't
targeted, loses the same entrypoint row, marker and traceparent, and with
the echo the wrapping message: it is now nowhere, even expanded, as for
dang. The fixture notes say so.

Signed-off-by: Alex Suraci <[email protected]>
@vito
vito marked this pull request as ready for review November 22, 2026 20:33
The dispatcher now reads function error values from gqlerror, so a new
module's generated code imports it and engines should pre-warm it.

Signed-off-by: Alex Suraci <[email protected]>
@vito
vito merged commit fedaced into main Nov 24, 2026
63 checks passed
vito added a commit to dagger/dagger that referenced this pull request Nov 24, 2026
Pin go-sdk to dagger/go-sdk#113 (5ed109c), whose dispatcher writes a
function's error to the engine's DAGGER_FUNCTION_ERROR_PATH and whose
entrypoint raises the exec error that carries it as it is, and regenerate
the go fixture and the shared dep, a go-sdk module.

Every sdks-go golden now renders as its target, fail-api included, except
broken-default: its "┇ build ›" breadcrumb is still a placeholder, and the
real one lists the entrypoint's dagger/go calls. Its compiler error moved to
./main.go:93:9 when fail-api grew the fixture.

The dep's rows are now clean in every SDK's call-failing-dep goldens, as the
targets have them, so the Python ones drop the rows relaxed for it: the
::dagger-function-error:: echo and the failed "call module entrypoint". The
dep's failure also reaches Python as an ExecError, values and all, so its
traceback ends in dagger.ExecError rather than dagger.QueryError.

Go's fail-exec-wrapped, which records today's output since wrapping isn't
targeted, loses the same entrypoint row, marker and traceparent, and with
the echo the wrapping message: it is now nowhere, even expanded, as for
dang. The fixture notes say so.

Signed-off-by: Alex Suraci <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants