Repository navigation
Conversation
A function that failed on a generated entrypoint failed with the exit code of `python -m dagger.mod call`, the exec that runs it: "exit code: 2". Its error, and the error origin it names, stayed in the exec's log. An API error's message names the call that failed, so the process's exec became the origin instead of that call, such as a failed lint exec. The process has no current function call to return an error to, as the old runtime did with returnError. As in the Go and Java SDKs, `call` now ends its stderr with the error on a `::dagger-function-error::` line, and the generated entrypoint raises that error. The exec still fails, so a failed call is not cached. The error reported is the function's own: an exception with its type, an API error whole, and each error of a task group's group. A Dang raise carries only a message, so the error's values, such as an exec's exit code, stop at the entrypoint. The build is synced before the rescued call, so its failures still carry theirs. A module picks this up when its entrypoint is generated again. Signed-off-by: Alex Suraci <alex@dagger.io>
eunomie
approved these changes
Nov 13, 2026
vito
added a commit
to dagger/dagger
that referenced
this pull request
Nov 22, 2026
Pin the Python fixture's SDK to a fork of dagger/python-sdk#93, rebased on main, whose dispatcher writes the function's error to the engine's DAGGER_FUNCTION_ERROR_PATH, and regenerate it. Every sdks-python golden now renders as its hand-edited target, with these differences: - Stack traces are deferred, like wrapping: the function's logs keep the traceback Python prints, "ERROR [dagger.mod]" header included, in fail-native, fail-exec, call-failing-dep and broken-default. The error origins and the error echoed after the traceback are gone. - call-failing-dep keeps the go-sdk dependency's rows as they render today: its ::dagger-function-error:: echo and its failed "call module entrypoint" row are the Go SDK's to fix. - fail-exec-wrapped is still today's output, which these fixes change: no entrypoint row or error origins, and collapsed, the inner withExec with its logs instead of the dispatcher's "exit code: 2". The wrapping message is still lost. The fixture notes drop the failures the engine no longer has. Signed-off-by: Alex Suraci <alex@dagger.io>
vito
force-pushed
the
entrypoint-function-error
branch
from
November 22, 2026 03:22
db1e9c6 to
775e8d0
Compare
vito
marked this pull request as draft
November 22, 2026 03:22
When the engine gives a call's process DAGGER_FUNCTION_ERROR_PATH, a function's own exception, and an error importing the module's code, are shown as Python shows an uncaught exception, with only the user's frames: the SDK's, the generated clients', the standard library's and installed packages' frames go, in each chained exception too, and so does the "Unhandled exception while executing function" log line above it. The error file keeps the whole traceback. An API error that names no origin, such as an ID that fails to load, is shown the same way: the engine shows no call it comes from. One that names its origin is still not shown, the engine showing the call that failed with its logs. Old engines keep the full logs. Signed-off-by: Alex Suraci <alex@dagger.io>
The short traceback left out every frame under site-packages, but the runtime installs the members of a module's workspace, the user's own libraries among them, from their directories, not editable: an exception raised in one lost the line that raised it. Frames of a package installed from a local directory (PEP 610's direct_url.json) are the user's. An API error a task group raises arrives in an ExceptionGroup: the errors whose origin the engine shows are left out of it too, and nothing is shown when none is left. Signed-off-by: Alex Suraci <alex@dagger.io>
A namespace package is shared by the distributions in it, so a library from an index in the same namespace as a local workspace member counted as the user's: a frame is the user's when its file is one a distribution installed from a local directory installed. A group that loses no API error is shown as it is, keeping the user's own group type, rather than as the plain group split derives. Signed-off-by: Alex Suraci <alex@dagger.io>
An API error can fail a call before or after the function runs: naming the module's declarations, or loading its result's ID. With the function error file, `dispatch` now shows any API error the call fails with as one from the function is: a short traceback when it names no origin, nothing when the engine shows where it comes from. Such an error goes on as the API error, not wrapped as an invalid input or result, so the engine gets its origin. Old engines keep the wrapping and its log. Signed-off-by: Alex Suraci <alex@dagger.io>
An engine that implements the function error file sets
DAGGER_FUNCTION_ERROR_PATH on a call's process. The process then writes the
function's error there instead of the ::dagger-function-error:: line, and
the engine fails the call with it as the function's own error, as it does an
error returned with returnError. The exec still fails, so a failed call is
not cached.
The file holds {"message": ..., "values": {...}}: the error's message in
full, with the origin an API error names, and the values record_exception
gives a dagger.Error: the exception's type, message and stack trace, a
ModuleError's extra values, and an API error's extensions, whole, also when
the error wraps it. A calling module so sees an ExecError, exit code and
output included, as from a runtime's function.
The function's logs then say nothing the engine shows already: the error
isn't logged again after the traceback, an exception the function raised is
reported without its type, which the traceback names, and the error origins
([traceparent:...]) are left out of what the process logs.
On an engine without the variable, the process reports the error as before.
Signed-off-by: Alex Suraci <alex@dagger.io>
A report over the engine's 1 MiB limit is dropped whole, so trim it to fit: the stack trace goes first, then the message and string values are cut. Take an API error's values only from the exception it was raised from, not one it was raised while handling, and keep a FunctionError's own extra values beside its cause's. Signed-off-by: Alex Suraci <alex@dagger.io>
function_error_values also takes an API error's values from the exception it was raised from, which record_exception does not. Signed-off-by: Alex Suraci <alex@dagger.io>
On an engine that gives the call's process DAGGER_FUNCTION_ERROR_PATH, a function's error keeps its values; only older engines get the message alone. Signed-off-by: Alex Suraci <alex@dagger.io>
When the engine gives a call's process DAGGER_FUNCTION_ERROR_PATH, an API error that escapes a function is no longer logged with its traceback. The engine fails the call with the error the file reports and shows its origin, the call that failed with its logs; the traceback ending in `dagger.ExecError: exit code: 1` only dominated the output. The report keeps the full values, stack trace included, and old engines still get the log and the marker. Signed-off-by: Alex Suraci <alex@dagger.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A function that fails on a generated entrypoint now fails with its own error, values and all, instead of with the exit code of the
python -m dagger.mod callexec that runs it.Depends on the engine in dagger/dagger#15249, which defines the contract this uses. Keep this a draft until that lands.
Why not
returnErrorThe process an entrypoint starts has no current function call to return an error to. The engine gives that exec the module but not the call, because an exec that holds a call cannot be persisted (dagger/dagger
withExecDynamicInputs). So the error comes back beside the exec, the way the result comes back through/dagger/result.json.The dispatcher
On an engine with dagger/dagger#15249, the call's process gets
DAGGER_FUNCTION_ERROR_PATH. When the function fails,python -m dagger.mod callwrites a report there and still exits non-zero, so a failed call is not cached:{ "message": "exit code: 1 [traceparent:…]", "values": { "exception.type": "dagger.ExecError", "exception.message": "exit code: 1 [traceparent:…]", "exception.stacktrace": "Traceback (most recent call last): …", "_type": "EXEC_ERROR", "cmd": ["sh", "-c", "echo exec stdout; …; exit 1"], "exitCode": 1, "stderr": "exec stderr", "stdout": "exec stdout" } }(This is what a function that lets an
ExecErrorpropagate writes.)messageis the error in full, any[traceparent:…]included, so an API error keeps the failed call it names as its origin.boom, notValueError: boom). The traceback, which names the type, is already in the function's logs, and the type is inexception.type.ExceptionGroupgives each of its errors, the way a task group raises them.valuesare the onesrecord_exceptiongives adagger.Error:exception.type,exception.messageandexception.stacktrace;extra.*for aModuleError'sextra. AFunctionErrorraisedfromanother error keeps its ownextranext to its cause's values.from. An exception raised while handling an API error is its own error and doesn't take the API error's values.[traceparent:…]. If it still doesn't fit, only the message is written.ExecErrorwith the inner exit code and output, anddagger callexits with the inner exec's code.The traceback is logged as before. With the file set, a
ModuleError/QueryErrormessage is not logged a second time, since the engine shows it.Error origins in logs
With the file set, the
dagger.modlogger gets anErrorOriginFilter. It strips[traceparent:…]from logged messages and tracebacks: the engine reads the origin from the report, and in the function's logs it's noise.Older engines
Without
DAGGER_FUNCTION_ERROR_PATH, the dispatcher falls back to a marker, the same one the Go and Java SDKs use. It ends its stderr with::dagger-function-error::<JSON string>: the message with the exception's type, e.g.ValueError: boom, cut to 16 Ki characters with any[traceparent:…]from the cut part kept, because a failed exec only passes on the end of its stderr.The generated entrypoint's
call()rescues the exec'sGraphQLErrorand raises the last marker line's message.os._exit, OOM), and on a new engine it hands the engine the exec error that carries the report.On those engines only the message gets past the entrypoint: a Dang
raisecarries no values. The README's note on function errors describes both cases.Existing modules pick this up on
dagger generate.Checks
pytest testspasses (605 tests). New unit tests cover:ModuleError/FunctionErrorextras;ruff checkandruff format --checkpass.mypyreports one error at_exceptions.py:99(transform_error), which was already there.sdks-python-*TUI goldens there pass against it. They cover native errors, exit codes, propagated and wrappedExecErrors, failing dependencies and a broken module.entrypoint-function-error-checke2e commit is gone from this branch. Those goldens, and the engine's own function-error integration tests in that PR, take its place.