Skip to content

Report function errors in the engine's error file - #11

Draft
vito wants to merge 2 commits into
mainfrom
function-error-file
Draft

vito wants to merge 2 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's function error file (DAGGER_FUNCTION_ERROR_PATH) and the golden tests this is checked against (dagql/idtui, sdks-ruby-*). The Ruby counterpart of dagger/go-sdk#113, dagger/python-sdk#93, dagger/typescript-sdk#144, dagger/java-sdk#47 and dagger/php-sdk#49. Keep this a draft until that lands.

What users saw

The generated entrypoint declared callDigest but marked no exec with it, so on an engine with the module process marker no exec was the module process:

  • every failure rendered on the dispatcher's own withExec ruby -rbundler/setup sdk/exe/dagger-mod call … row, with its stdin, ! exit code: 2, and the full stack trace through Dagger::Mod::Dispatch, CLI and the generated clients;
  • a function's own error was wrapped in Dagger::Mod::FunctionError, its message the whole full_message of the original;
  • a function's logs never reached its row, which showed only its result;
  • a module file that didn't parse showed syntax_suggest's guess ("Unmatched keyword, missing `end' ?", pointing at the file's first lines) above Ruby's error.

What changes

  • The module process. call sets DAGGER_MODULE_CALL_DIGEST to its callDigest on the dispatcher's exec, and on no other, after syncing the install: the install is the module's build, the dispatcher its process, which gets the module, the function's span and the error file. The digest no longer rides in the request.
  • prebuild. The entrypoint declares it, a file of the installed container (Gemfile.lock), so the engine builds the gems' install ahead of the call, under build <module>.
  • Errors in the engine's file. Dispatch no longer wraps what module code raises. dagger-mod call reports it (new Dagger::Mod::ErrorReport) and exits 2 (1 when the module's code doesn't load, as before):
    • with DAGGER_FUNCTION_ERROR_PATH, it writes {"message", "values"}: the message whole, its [traceparent:…] origins kept, and the extensions of the first API error in the error's chain of causes, verbatim, so a caller gets a typed ExecError with its exit code and output. A report over the engine's 1 MiB is shortened (long strings keep their end, the message its start and origins, then the values go).
    • call() raises the exec's error unchanged when it carries the engine's functionError.
  • Short traces, in Ruby's own form. With the file, the logs get the error as Ruby prints an uncaught one (path:line:in 'Class#method': message (Class), \tfrom lines, causes after), through the module's own frames only: not the SDK's, the generated clients/, the installed gems' or Ruby's library. A path gem the module uses outside its directory keeps its frames. [traceparent:…] is stripped. A stack overflow is shortened as Ruby shortens it (... N levels...); error_highlight's snippet stays only when the frame that raised is the module's.
  • Nothing for what the engine shows. An API error that names its origin logs nothing (the engine shows the failed call with its logs), nor does an error of the SDK's own (Dagger::Mod::Error), whose message the engine shows; the dagger generate hint still follows a stale call.
  • SyntaxError. A module file that doesn't parse logs Ruby's own error, without syntax_suggest's guess, and reports its first line (/src/lib/x.rb:86: syntax errors found), which names the file and the line.
  • Older engines (v1.0.0-beta.27, this repository's CI) keep working: without the file, the error goes to stderr as Ruby prints it, whole, followed by a last ::dagger-function-error::<JSON string> line (cut to 16 KiB, origins kept), which call() raises as the function's error. Without a marker, as after an exit, it raises the exec's error.
  • An exit of the function's own ends the process with its status and reports nothing: the engine fails the call with exit code: N.

Dagger::Mod::FunctionError is gone: nothing raises it any more. README, AGENTS.md, the design note and CHANGELOG.md describe the new behavior.

Testing

  • New test/mod/error_report_test.rb, and dispatch_test.rb/entrypoint_test.rb cases: the report's message and values (native, API, wrapped, SDK errors, empty messages, invalid UTF-8, the 1 MiB trim), the short trace's frames, causes, stack-overflow shortening and error_highlight, SyntaxError, the marker fallback, the CLI's exit statuses with and without the file, and the rendered entrypoint (marker env on the dispatcher's exec only, prebuild, the rescue).
  • dagger check -m .dagger/modules/e2e sdk-test-check sdk-lint-check sdk-types-check pass; so do error-check, missed-generation-check, entrypoint-client-call-check, function-cache-check, types-round-trip-check and vendoring-check.
  • core, idtui: readable errors from entrypoint SDK modules dagger#15249's TestTelemetry/TestGolden/sdks-ruby-* goldens (17, incl. log-success) all pass against this branch, pinned by SHA (6ba32f1) at a42d564 of viztest-external-sdks. They were hand-written as targets before this branch existed, and pass unchanged.
  • dagger generate was run for the vendored sdk/ of the e2e harness and the entrypoint goldens; the core clients' drift from the generating engine's schema is left out.

vito added 2 commits November 22, 2026 23:10
A failed call fails with its own error: in the engine's function error file
(DAGGER_FUNCTION_ERROR_PATH, dagger/dagger#15249), with the values of the API
error it was raised from, and a short trace of the module's own frames in its
logs, in Ruby's own form; nothing for an API error whose origin the engine
shows. On an older engine, Ruby's full trace and a ::dagger-function-error::
marker line, which the generated entrypoint raises.

The entrypoint now marks its function's exec, and no other, with
DAGGER_MODULE_CALL_DIGEST: without it, no exec was the module process, and the
function's logs and errors rendered on the dispatcher's exec. It declares the
gems' install as prebuild, so the engine builds it as the module's build.

Signed-off-by: Alex Suraci <alex@dagger.io>
Address review: a stack overflow's short trace is shortened as Ruby's own
printer shortens it; error_highlight's snippet is left out when the frame that
raised is not the module's, which heads the trace instead; messages with
invalid UTF-8 are scrubbed before any string operation; a module file that
doesn't parse exits 1 again, as before, without the generate hint.

Signed-off-by: Alex Suraci <alex@dagger.io>
vito added a commit to dagger/dagger that referenced this pull request Nov 23, 2026
Pin ruby-sdk to dagger/ruby-sdk#11 (6ba32f1) and regenerate the fixture: its
entrypoint marks the dispatcher's exec as the module process and declares
prebuild, and the dispatcher reports a function's error in the engine's file,
with a short trace of the module's own frames in Ruby's own form. Every
sdks-ruby golden now matches its target, unchanged.

Signed-off-by: Alex Suraci <alex@dagger.io>
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.

1 participant