Repository navigation
entrypoint: report errors in the engine's function error file - #144
Merged
Merged
Conversation
A generated Dang entrypoint for a function with @func({ cache: "session" }) fails to load: `field "PerSession" not found in Dagger.FunctionCachePolicy`. The Dang renderer emitted the TypeScript client's member names; Dang names enum members by their GraphQL values. Emit PER_SESSION, NEVER and DEFAULT instead. Same change as #142, which was closed unmerged. Signed-off-by: Alex Suraci <[email protected]>
bundle/index.ts, which every module gets as clients/dagger/index.ts, names its exports one by one and left the error classes out, so a module could not import ExecError to catch a failed exec and read its exit code. The library barrel already exports them, through `export * from "@dagger.io/session"`. Signed-off-by: Alex Suraci <[email protected]>
A dispatcher under a module entrypoint replied on stdout, which the function's own console.log shares: a function that logged and returned failed with "JSON.decode: invalid JSON", and one that logged and threw lost its message to "exit code: 2". A module that didn't compile failed the process before the dispatcher ran, as "exit code: 1". - The result goes to /dagger/result.json, named on the command line, which call() reads back once the exec succeeded. - A failed call's error goes to the function error file the engine names in DAGGER_FUNCTION_ERROR_PATH (dagger/dagger#15249): the full message, origins kept, and the extensions of the API error it is or wraps, followed by exit code 2. call() raises the exec error unchanged when it carries the engine's functionError. An engine without the file gets a `::dagger-function-error::` marker on stderr, as go-sdk prints it. - In error-file mode the call's logs get a short stack trace of the module's own frames only, causes included and traceparents stripped, and nothing for an API error whose origin the engine shows. A TransformError, the module failing to compile, is esbuild's own error lines, with its summary as the call's message. - The module's code is imported for its types only and loaded with import() by loadModule, so a load or compile error is reported like any other. There is no prebuild: tsx compiles at run time, so there is no build step to show under `build <module>`. Signed-off-by: Alex Suraci <[email protected]>
- Bun's AggregateError for a module that doesn't build lists the BuildMessages it holds, each with its position, and a thrown non-Error with a message, such as Bun's ResolveMessage, is reported by its message rather than as JSON. - A short stack trace stops at an API error: its cause is graphql-request's ClientError, whose message is the whole response and request. - An error's own extensions are its values, as the builtin runtime's formatError reports them; only without them do the values come from an API error it wraps. - The old-engine marker carries a compile error's whole message, since an older engine doesn't show the logs that hold its details. - Comments and the design doc describe the result file and the function error file instead of the stdout reply. Signed-off-by: Alex Suraci <[email protected]>
vito
added a commit
to dagger/dagger
that referenced
this pull request
Nov 22, 2026
Pin typescript-sdk to dagger/typescript-sdk#144 (28249a5, on top of #143) and regenerate the TypeScript fixture. Its dispatcher returns the result in /dagger/result.json instead of on stdout, writes a function's error to the engine's DAGGER_FUNCTION_ERROR_PATH, and loads the module's code itself, so a compile error is reported as the call's error; its entrypoint raises the exec error that carries it as it is. The module's @dagger.io/dagger exports ExecError now, so fail-exec-wrapped catches one and wraps it with a cause, as the other fixtures do. The clients/sdk-dep client is kept as it was: generation from this checkout re-targets it. Goldens: - fail-native: a short stack trace, the error and the user's one frame, as Java and Python show one. - fail-exec-wrapped (today's output, not a target): the cause chain, each part through the user's frame only, and no reply JSON, traceparents or "call module entrypoint" row. It no longer races, so it isn't Flaky, and the sdkFixture racy field goes with it. - broken-default: esbuild's line is 84:5. The other targets pass unchanged, log-success included. Every sdks-typescript golden passes. Signed-off-by: Alex Suraci <[email protected]>
This was referenced Nov 22, 2026
vito
marked this pull request as ready for review
November 22, 2026 20:33
sipsma
approved these changes
Nov 24, 2026
vito
added a commit
to dagger/dagger
that referenced
this pull request
Nov 24, 2026
Pin typescript-sdk to dagger/typescript-sdk#144 (28249a5, on top of #143) and regenerate the TypeScript fixture. Its dispatcher returns the result in /dagger/result.json instead of on stdout, writes a function's error to the engine's DAGGER_FUNCTION_ERROR_PATH, and loads the module's code itself, so a compile error is reported as the call's error; its entrypoint raises the exec error that carries it as it is. The module's @dagger.io/dagger exports ExecError now, so fail-exec-wrapped catches one and wraps it with a cause, as the other fixtures do. The clients/sdk-dep client is kept as it was: generation from this checkout re-targets it. Goldens: - fail-native: a short stack trace, the error and the user's one frame, as Java and Python show one. - fail-exec-wrapped (today's output, not a target): the cause chain, each part through the user's frame only, and no reply JSON, traceparents or "call module entrypoint" row. It no longer races, so it isn't Flaky, and the sdkFixture racy field goes with it. - broken-default: esbuild's line is 84:5. The other targets pass unchanged, log-success included. Every sdks-typescript golden passes. Signed-off-by: Alex Suraci <[email protected]>
TomChv
added a commit
that referenced
this pull request
Nov 25, 2026
`e2e/sdk/helper-tests-check` is red on main: `go test ./...` in helpers/codegen fails TestGenerateDangEntrypointCachePolicy (3 subtests) and TestGenerateEntrypointDispatchLoadsModuleCode. Neither is a regression in #120's code, and neither PR could have caught it. #120 made every generator that renders a module's own declarations ask the engine for their names, and added `Naming` to each test that builds a generator config. Its branch predates both of these tests: - dang_entrypoint_cache_policy_test.go arrived with #143. - TestGenerateEntrypointDispatchLoadsModuleCode arrived with #144. Both merged after #120's CI ran, git merged all three cleanly, and the combination was never tested. Without a naming context the dang entrypoint finds no main object among typedef_smoke.json's objects, and the dispatcher cannot name the fixture's own interface. Both now use `smokeNaming()`, as every other test on that fixture does. Signed-off-by: Tom Chauveau <[email protected]>
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.
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-typescript-*). The TypeScript counterpart of dagger/go-sdk#113, dagger/python-sdk#93 and dagger/java-sdk#47.This branch includes #143 (generated Dang entrypoints name cache policies in GraphQL's spelling), which is still open: the fixture doesn't load without it. Merge #143 first, or this along with it.
What users saw
Under a module entrypoint, the dispatcher replied on stdout, which the function's own
console.logshares:JSON.decode: invalid JSON;exit code: 2;exit code: 1, with node's crash dump in the hidden logs;console.error(e)(for an API error, the whole GraphQL response) and the reply JSON onto the function's row;ExecErrorwasn't exported from a module's@dagger.io/dagger, so it couldn't be caught.What changes
/dagger/result.json, named on its command line, andcall()reads it back. stdout is the function's again.DAGGER_FUNCTION_ERROR_PATH, a failed call writes{"message", "values"}there and exits 2. The message is full, with its[traceparent:…]origins. The values are the error's ownextensions, else those of the API error it wraps throughcause.call()raises the exec error unchanged when it carries the engine'sfunctionError, so callers get a typed error, values and all. Older engines, or a file that can't be written, get the previousconsole.error(e)plus a::dagger-function-error::marker on stderr, as go-sdk prints it.node_modules,*.gen.*,clients/and the dispatcher itself are dropped, causes print asCaused by:, and traceparents are stripped. An API error with an origin prints nothing: the engine shows the failing call with its own logs.import type), and loads it withimport()once it is running. A compile error from tsx (TransformError) reports esbuild's summary as the message, and its error lines as the logs. Bun'sAggregateErrorlists itsBuildMessages with their positions.ExecErrorand friends are exported from the bundled barrel.prebuild. tsx compiles at run time, so there is no build step to show underbuild <module>.Testing
go test ./...inhelpers/codegen; the dispatch and Dang goldens were regenerated.node:24+ tsx andoven/bun:1.3.0with a stubbed SDK, covering: success after a log; a native throw; an ExecError with an origin; a wrapped ExecError; a syntax error; and the old-engine marker.sdks-typescript-*goldens on core, idtui: readable errors from entrypoint SDK modules dagger#15249 pass with this pinned.