Skip to content

fix: use GraphQL cache policy enum values in Dang entrypoints - #143

Merged
vito merged 1 commit into
dagger:mainfrom
vito:dang-cache-policy-enum
Nov 24, 2026
Merged

vito merged 1 commit into
dagger:mainfrom
vito:dang-cache-policy-enum

Conversation

@vito

@vito vito commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

A generated Dang entrypoint for a function with @func({ cache: "session" }) fails to load on current engines:

module "…" entrypoint sources: field "PerSession" not found in Dagger.FunctionCachePolicy

The Dang renderer emitted the TypeScript client's enum member names (PerSession, Never, Default); Dang names enum members by their GraphQL values. This emits PER_SESSION, NEVER and DEFAULT, with a regression test over all three policies.

Same change as #142, which was closed unmerged. Found while adding external-SDK golden tests to dagger/dagger's TUI suite.

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 dagger#142, which was closed unmerged.

Signed-off-by: Alex Suraci <[email protected]>
@vito
vito merged commit 37d6a4d into dagger:main Nov 24, 2026
6 checks passed
vito added a commit to dagger/dagger that referenced this pull request Nov 24, 2026
Add fixture modules built with the external, entrypoint-style SDKs (go,
python, typescript, php, java, and dang), each with the same functions: one
that logs and succeeds, one that logs and fails natively, one that exits with
a code, a failing withExec left unhandled and caught-and-wrapped, and a call
into a go-sdk dependency whose withExec fails. A copy of each fixture with a
syntax error appended, made by the test, covers an SDK's own build or load
failing before any function runs.

The goldens pin today's output, warts and all, to plan fixes against; the
fixture comments in golden_sdks_test.go name what is wrong per SDK. Each
failing case also has a collapsed, quiet variant, as a user sees it.

The fixtures are generated from viztest/sdks/dagger.toml, a workspace of
their own so that regenerating them never touches the repository's config.
Two SDKs are pinned to forks with fixes the fixtures need to run at all:
php-sdk's sdk-helpers no longer compiles under current Dang
(dagger/php-sdk#48), and typescript-sdk's Dang entrypoint misspells cache
policies (dagger/typescript-sdk#143).

Expanded reports elide what a module entrypoint evaluates: the Dang
entrypoint runs it concurrently, so its order varies run to run. The suite's
cleanup now removes the dagger.lock the fixtures' image pulls write.

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]>
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