Repository navigation
Conversation
A Dang function that raises a Dagger Error now fails with that Error, values and all: the runtime records it as the call's returned error, as FunctionCall.returnError does for a module process, so a caller sees an ExecError's exit code and output rather than a new error with its message. An SDK entrypoint, whose process can't call returnError, can then hand on the Error the process built by loading it by ID and raising it. The ID is read while the nested client still serves, since it can take a query. A rescued GraphQL error raised again as it was is converted from the error it came from, so it keeps its extensions too. Signed-off-by: Alex Suraci <[email protected]>
sipsma
approved these changes
Nov 12, 2026
sipsma
added a commit
to dagger/go-sdk
that referenced
this pull request
Nov 13, 2026
On the Go runtime, a function that returns the error of a failed exec fails with that error's exit code, stdout and stderr: its process returns a Dagger Error that carries them. On the Dang entrypoint, the dispatcher reported only the error's message, and the entrypoint raised that. So the caller saw "exit code: 1" without the output. From v1.0.0-beta.28 on, the release that has dagger/dagger#15161, a failed function's dispatcher builds a Dagger Error as the Go runtime does: the message of the GraphQL error the function returned, and each of its extensions as a value. It then reports the Error's ID after the message. The entrypoint loads the Error by its ID and raises it, and the engine hands the caller that Error. Its traceparent still points at the exec that failed. If the Error can't be built, the entrypoint raises the message as before. Modules that target an older release keep the message, since their engines can't raise an Error. The e2e fixture's function fails with an exec that prints output and exits with 42. Its caller gets an exec error with that exit code and output. That needs an engine with #15161, which no release has, so the check runs from engine-e2e on a supplied engine source and isn't in CI yet. Signed-off-by: Erik Sipsma <[email protected]>
TomChv
pushed a commit
to dagger/typescript-sdk
that referenced
this pull request
Nov 16, 2026
* entrypoint: don't cache a call that threw The dispatcher of an entrypoint module exited 0 when the function threw, replying with the error on stdout for the entrypoint to raise. The exec therefore succeeded and was cached under the call digest: dagql keeps no result for the failed call, so the next evaluation ran the entrypoint again, its exec answered from the cache, and the same error came back without the function running. A flaky failure stuck until the exec was pruned. The dispatcher now exits 2 after an error reply, so the exec fails and is not cached. A failed exec keeps the tail of its stdout in its error, so the entrypoint rescues it and raises the message from the reply there, or the exec's own error when there is none. The message is capped to fit that tail, keeping the traceparents it cuts. runtimes:entrypoint-failure-reruns-check calls a function that throws a new nonce twice, on node, bun and deno; before this it got the same nonce back. Signed-off-by: Alex Suraci <[email protected]> * entrypoint: build before the rescued call exec Review follow-ups to the previous commit. The call's container is synced before the dispatcher's exec, outside the rescue, so a failed install keeps its own error and values instead of only the message a re-raise keeps on engines before dagger/dagger#15161. The error reply is cut to the bytes it can take in the failed exec's 100 KiB stdout tail, measured on the encoded reply, rather than to 16 Ki characters, so a long ASCII report is no longer cut short. The comments say what tells a function's failure from the dispatcher's: the reply, not the exit code. Signed-off-by: Alex Suraci <[email protected]> --------- Signed-off-by: Alex Suraci <[email protected]>
eunomie
pushed a commit
to dagger/go-sdk
that referenced
this pull request
Nov 16, 2026
* feat(go): target v1.0.0-beta.27 beta.27 is the newest release of dagger.io/dagger, and the default had stayed at beta.25 since beta.25 was the newest. The release in flight a scope can pin moves to beta.28. Signed-off-by: Erik Sipsma <[email protected]> * test(go): run the e2e checks on the default target's engine A module generated for beta.27, the default target, uses that release's naming and lists dagger/go as its entrypoint's dependency, and a beta.18 engine can't load either. Build the e2e engine from beta.27, and expect a new module's manifest to list dagger/go. The floor checks keep their own older engines. Signed-off-by: Erik Sipsma <[email protected]> * test(go): keep the sources check on the beta.18 floor engine beta.27 reads a module's include in place of calling its sources function, so the sources check on the e2e engine no longer ran sources. Run it, and the manual floor checks, on beta.18 as before, with fixtures that target the floor release. Signed-off-by: Erik Sipsma <[email protected]> * test(go): drop the unused dang-sdk from the e2e workspace No check uses it, and its locked commit doesn't load on beta.27, which runs a load check for every module of a workspace, so every check failed. Signed-off-by: Erik Sipsma <[email protected]> * test(go): expect beta.27's entrypoint builds and a valid runtime module From beta.26 the go build entrypoint writes its binary into a directory it declares for a platform, /tmp/dispatch/dispatch. And beta.27's built-in Go SDK compiles a module's packages to generate its code, so the runtime steps of the compatibility check get a main.go with package main, as a module on the Go runtime has. Signed-off-by: Erik Sipsma <[email protected]> * test(go): check generation's uploads from a session's own client The ignore checks read the engine's upload spans from the collector of the CLI they run. That CLI ran nested in an exec, and since dagger/dagger #15100 a nested CLI no longer passes the engine's spans to its collector, so on beta.27 the checks saw no upload at all. Run them from engine-e2e, where the CLI is a client of the engine under test in its own session. The beta.18-24 driver goes with them: engine-e2e runs them on beta.27. Signed-off-by: Erik Sipsma <[email protected]> * fix(go): import a new runtime module's bindings by its go.mod's path A new module on the Go runtime in a directory that already has a go.mod got a starter that imports dagger/<name>/internal/dagger, whatever module path the go.mod declares, so the module didn't build. Render the starter with that go.mod, as a new entrypoint module's already is. Signed-off-by: Erik Sipsma <[email protected]> * test(go): commit the entrypoint's dang.toml in the git-source check This repository's .gitignore ignores dang.toml, so the git module the check builds had no entrypoint dang.toml, and the engine served it at its fallback release, beta.24. Code for beta.27 calls Directory.withPlatform, which that release lacks. A module commits the file, as the README says. Signed-off-by: Erik Sipsma <[email protected]> * fix(go): generate a collection module that builds with dagger/go A module with a +collection type builds its process from runtime sources that generation prepares beside it. Generation overlays them on the module context in the entrypoint, and could only find the context in a go build entrypoint, which mounts it twice. An entrypoint that builds with dagger/go reads the context as a workspace in dispatch and mounts it once in call, so generation refused it: every new module with a collection failed once dagger/go became the default build. Overlay the runtime sources on the workspace dagger/go builds from as well. Signed-off-by: Erik Sipsma <[email protected]> * fix(go): mount Go cache volumes around go build only for targets dagger/go can't build A generated entrypoint that builds its module's process with go build mounted the go-sdk-v2-mod and go-sdk-v2-build cache volumes for every target. The build is one exec, which the engine caches by its inputs, so the volumes only carry downloads and compiled packages from one build to the next outside that cache. A module that targets v1.0.0-beta.26 or later can build with dagger/go's per-package build instead. dagger/go's gobuild, which does that per-package build, is itself built with go build, so every per-package build used these volumes through it. Mount them only for a target older than dagger/go's floor, whose engines can't run the per-package build. Signed-off-by: Erik Sipsma <[email protected]> * feat(go): build existing entrypoint modules with dagger/go An existing module kept go build when it was generated again, even for a target whose engines run dagger/go's per-package build, unless it set daggerGo = true. Only new modules got the per-package build, and now that go build mounts no Go cache volume for those targets, an existing module on it rebuilt every dependency after each edit. Unset daggerGo now selects dagger/go for every entrypoint module that targets v1.0.0-beta.26 or later, new or existing. daggerGo = false keeps go build. A module that targets an older release builds with go build, as before. The checks that migrate an existing module expect dagger/go; the checks of go build's compiler image set daggerGo = false. Signed-off-by: Erik Sipsma <[email protected]> * feat(go): keep a module's Go code in a subdirectory of its directory A module can keep its Go code in a subdirectory of the directory that holds its manifest, as "source": "runtime" says in dagger.json. Generating it with dangEntrypoint refused that source, so such a module could move to a Dang entrypoint only by making the subdirectory the module's root, which changes the reference the module is loaded by. Generation now keeps the layout. The go.mod, the generated Go files and the entrypoint go into the subdirectory, and dagger-module.toml stays in the module directory and names the entrypoint there, such as ./runtime/internal/dagger/entrypoint. The next generation finds the Go code from that path. The generated entrypoint builds and runs the subdirectory, and source maps name files from the module directory. A source outside the module directory is still refused. A module in a subdirectory whose build reads files outside the subdirectory is refused too: its include list would have to name paths from the module directory. Signed-off-by: Erik Sipsma <[email protected]> * fix(go): read a collection's runtime sources from the module's Go code A collection's runtime sources are written beside the entrypoint, in the module's Go code directory, but the entrypoint read them from the module directory. In a module whose Go code is in a subdirectory, it looked for them in the wrong place. The entrypoint now reads them from the Go code directory, as it builds the module. The docs also say what changes for a module's own code: the module directory, not the subdirectory, is now its source. Signed-off-by: Erik Sipsma <[email protected]> * test(go): gofmt the collection build test Signed-off-by: Erik Sipsma <[email protected]> * fix(go): give a module the description of its package's doc comment A module on the Go runtime takes its description from its package's doc comment. On the Dang entrypoint the description was dropped: the entrypoint returned only the module's types, and the doc comment reached neither the entrypoint nor the manifest. The generated entrypoint now returns the doc comment from a description member, which the engine reads as it reads prebuild and runtimeImage. An engine that doesn't read the member ignores it, and a module without a doc comment gets no member. Signed-off-by: Erik Sipsma <[email protected]> * fix(go): check the entrypoint at the Dang version it declares Generation type-checks the entrypoint it writes with the entrypoint-contract helper, which checked it at its own Dang's current version. The engine evaluates the entrypoint at the version its dang.toml declares, 2.1. The two agreed while the helper's Dang was v2.1.4. The helper now moves to the Dang that the engine uses (683ac69d8a), whose interfaces are structural, so the helper accepts an entrypoint that raises a Dagger Error, as the engine does. That Dang refuses forms that 2.1 allows, such as a bare type pattern. So generation passes the helper the version it declares in dang.toml, and the helper checks the entrypoint at that version. Signed-off-by: Erik Sipsma <[email protected]> * fix(go): hand a function's caller the engine's error, values and all On the Go runtime, a function that returns the error of a failed exec fails with that error's exit code, stdout and stderr: its process returns a Dagger Error that carries them. On the Dang entrypoint, the dispatcher reported only the error's message, and the entrypoint raised that. So the caller saw "exit code: 1" without the output. From v1.0.0-beta.28 on, the release that has dagger/dagger#15161, a failed function's dispatcher builds a Dagger Error as the Go runtime does: the message of the GraphQL error the function returned, and each of its extensions as a value. It then reports the Error's ID after the message. The entrypoint loads the Error by its ID and raises it, and the engine hands the caller that Error. Its traceparent still points at the exec that failed. If the Error can't be built, the entrypoint raises the message as before. Modules that target an older release keep the message, since their engines can't raise an Error. The e2e fixture's function fails with an exec that prints output and exits with 42. Its caller gets an exec error with that exit code and output. That needs an engine with #15161, which no release has, so the check runs from engine-e2e on a supplied engine source and isn't in CI yet. Signed-off-by: Erik Sipsma <[email protected]> * fix(go): leave main-client-only calls out of unified module bindings The Go runtime generates a module's bindings from the schema the engine serves module SDKs, which leaves out what only the engine's main client may call: host, engine, currentWorkspace, engineVolume, sshfsVolume and setSessionTitle. So module code that calls dag.Host doesn't compile. A module's unified bindings embedded all of dagger.io/dagger/core's Query instead, so the same code compiled. The unified bindings now forward each core field of the module schema's Query to core's Query, and nothing else. The list is the schema the engine serves, not a copy. Module code that calls dag.Host, dag.Engine or dag.CurrentWorkspace fails to compile with "undefined", as on the Go runtime, while the rest of core's Query is still offered. Signed-off-by: Erik Sipsma <[email protected]> * fix(go): forward only the core fields the module's library has Unified module bindings forward each core field of the module schema's Query to dagger.io/dagger/core's Query. An engine can serve an older release's view fields added after that release: a beta.27 engine serves identifier, formatIdentifiers and namingDictionary in beta.18's view, which beta.18's library lacks. So a unified module that targets beta.18 failed to compile on that engine: "r.coreQuery.Identifier undefined". Generation now reads the methods of core.Query from the library the module builds with, the replacement's when go.mod replaces it. The bindings forward only the fields of the module schema that the library has. The e2e check generates such a module for beta.18, and it compiles. Signed-off-by: Erik Sipsma <[email protected]> * fix(go): read the library that go.mod's replacement of its version selects Go applies a replacement of a module's selected version over one of every version, whichever comes first in go.mod. When go.mod had both for dagger.io/dagger, QueryMethods read the library of whichever came last. So unified bindings could forward fields the library Go builds with lacks, the failure the previous commit fixes. It now reads the replacement of the version when there is one, else the one of every version. Signed-off-by: Erik Sipsma <[email protected]> * fix(go): name the generated entrypoint's images from versions.toml Generation wrote the runtime image, and the Go image a go build entrypoint builds in, by the digest the session resolved their tags to. That digest is whatever the workspace's lock or the registry holds when generation runs: dagger/dagger's lock, go-sdk's and a workspace without an entry resolve alpine:3.22 to three different digests. A module generated in one place, or before a tag moved, was stale in another, and the stale check failed on changes that touched no module. versions.toml now pins both images by digest, and generated code changes only when it does. A module on another Go version than the default names that version's tag, which its build looks up. Signed-off-by: Erik Sipsma <[email protected]> --------- Signed-off-by: Erik Sipsma <[email protected]>
vito
force-pushed
the
dang-raised-errors
branch
from
November 17, 2026 21:20
57f1859 to
6db9936
Compare
Contributor
Author
|
This got pulled in as part of #15143 apparently! |
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 Dang function can now fail with a real
Error, values included, instead of only a message. This is the engine half of getting module errors through Dang entrypoints intact. Today an SDK entrypoint can onlyraisea string, so a function'sExecErrorreaches its caller ascall module entrypoint: exit code: N. That error has no exit code, no stdout/stderr, and points at the entrypoint exec as its origin.Changes
mainwithout waiting for the 2.5 tag, to pick up Structural interfaces across schemas; raise any Error-shaped value vito/dang#306. Interfaces declared in Dang are now structural, so aDagger.Error!satisfiesErrorand can beraised. A rescued error that is raised again as it was keeps the Go error it came from (RaisedError.Origin). The bump also brings Dang 2.5 strings (Interpolate in double-quoted strings (Dang 2.5) vito/dang#300). Only modules that declaredang = "2.5"see those, because no engine version defaults to 2.5 yet.Dagger.Error!fails the function with that Error (core/sdk/dang/v2/errors.go):FunctionCall.ReturnError, andmodfuncloads it exactly as it loads an error from a classic module process'sreturnError. A caller then sees theExecError's exit code and output.x rescue { e: GraphQLError => raise e }is converted from the error it came from, as if nothing had rescued it."${}"interpolates only underdang = "2.5". The embedded dang-language skill now teaches 2.5 strings, and at 2.4 such a string is literal text with no error.Why this is needed
An entrypoint's module process has no
FunctionCall, because an exec holding one can't be persisted. So the process can't callreturnErroritself. With this change, an SDK dispatcher can build theError(as the classic runtimes did) and print its ID. The generated entrypoint then raises it after loading it withnode(id:). That SDK side comes later and is gated on an engine release that includes this change. Until then, the message marker from go-sdk/java-sdk (and dagger/python-sdk#93) keeps the message and the origin.Known caveat
Structural matching applies to
case/rescuetype patterns at every Dang version. In a module pinned to an older version, a type that has an interface's fields without declaring it now matches that interface's arm. So a later arm for that type is reported as unreachable. We accept that rather than gating it on the version, since such code is unlikely to exist yet.Tests
ModuleSuite/TestDangRaisedErrorValuescovers an entrypoint module and a native Dang module. For each, it raises aDagger.Errorthat carriesEXEC_ERRORvalues, and re-raises a rescued exec failure. It asserts that the caller gets a*dagger.ExecErrorwith exit code 42 and the exec's stdout and stderr. Without the change, all four cases fail.