Skip to content

fix: don't abort dagger generate when the entrypoint module can't load - #13774

Merged
grouville merged 2 commits into
dagger:mainfrom
grouville:fix-v1-entrypoint-generate
Jul 31, 2026
Merged

grouville merged 2 commits into
dagger:mainfrom
grouville:fix-v1-entrypoint-generate

Conversation

@grouville

@grouville grouville commented Jul 30, 2026 •

Copy link
Copy Markdown
Member

What was broken

A module that can't load is fixed by running dagger generate — that's what creates its missing generated files. But when the broken module was the workspace entrypoint, generate itself failed:

Error: ... loading module ".../greetings": generated file ".dagger/workspace/dagger.gen.go"
  is missing; run `dagger generate` and commit the generated files

Generate tells you to run generate. You're stuck. Every migrated v1 project with local dependencies lands in this state, because migration converts modules to the new format before their generated files exist (#13742).

Why it happened

Generate already expects broken modules: it loads them best-effort and skips the ones that fail.

The failure came from a later step. Before answering any query, the engine reads the query's first field to decide which modules it must load. Known core fields (container, currentWorkspace, ...) need none. An unknown field is assumed to be a function of the entrypoint module, so the engine force-loads it — and force-loading a broken module fails the query.

node — the field the SDK uses to fetch generate's results (changeset id, diff preview, export) — is a core field, but was missing from the known list. So right after generate skipped the broken entrypoint, its own follow-up queries force-loaded it and died. This is also why only entrypoint modules were affected: a broken non-entrypoint module leaves nothing to force-load.

The fix

Add node to the known core fields: it loads an existing object by ID and needs no module. Generate now skips the broken entrypoint (still warned, still fatal with --require-load) and generates everything else.

Repro

git clone https://github.com/kpenfound/greetings-api && cd greetings-api
dagger setup --auto-apply
dagger generate --no-apply   # failed before; now generates the missing files

Testing

First commit adds the red test: a workspace with a broken entrypoint module, where generate -l/-y/--no-apply all failed.

dagger call engine-dev test --pkg=./core/integration --run='^TestGenerators/TestWorkspaceGenerateSkipsBrokenEntrypoint$'

Also green: TestGenerators, TestWorkspaceCompat, TestModuleLoading and TestWorkspace (559 tests total), plus the greetings-api repro above on a dev engine. (greetings-api additionally needs the Go SDK generator work tracked in #13743 before dagger call works; this PR removes the hard failure in front of it.)

A separate commit restores the materializeModuleFiles helper: two independently merged commits left core/integration uncompilable on main.

Fixes #13742

@grouville

Copy link
Copy Markdown
Member Author

The first commit (restoring materializeModuleFiles) is split out as #13775 to unbreak main's integration-test compilation independently of this review. Once it merges I'll rebase and the duplicate commit will drop out.

@grouville grouville added this to the v1.0.0 milestone Jul 30, 2026
@grouville
grouville force-pushed the fix-v1-entrypoint-generate branch 4 times, most recently from 056e125 to 5d35122 Compare July 30, 2026 20:26
A workspace whose entrypoint module cannot load (issue 13742: a migrated
v1 module whose local dependencies are missing their generated files)
aborts every dagger generate mode, even though generate is the repair
for that state and already skips the module best-effort while listing.

Also cover the pre-migration shape from the issue: a legacy dagger.json
entrypoint project with local dependencies must keep call and generate
working.

Signed-off-by: Guillaume de Rouville <[email protected]>
The SDKs root every post-Sync handle at node(id:), so dagger generate's
follow-up queries (changeset id, diff stat, export) all peek as an
unrecognized root field. The unknown-field fallback then selected the
pending entrypoint module for a strict load — and since the generators
listing had already tried that module best-effort and recorded its
failure, the strict path replayed the recorded error, failing every
generate mode on a workspace whose entrypoint cannot load (e.g. a
migrated v1 module whose local dependencies are missing their generated
files). dagger#13742

The fallback is only a guess that the unrecognized field might be an
entrypoint function; a module already recorded as unloadable can't serve
anything, so guessing at it can only replay its load error. Thread the
client's failed-module record into the root-field demand filter and
leave such modules pending: requests that deliberately proceeded without
the broken module keep working against the served schema, and GraphQL
validation reports unresolved fields and types. A root field that names
a failed module directly still selects it, so explicit use still
surfaces the real load error.

Fixes dagger#13742

Signed-off-by: Guillaume de Rouville <[email protected]>
@grouville
grouville force-pushed the fix-v1-entrypoint-generate branch from 5d35122 to 849d5b3 Compare July 30, 2026 22:07
@grouville
grouville merged commit a7790b2 into dagger:main Jul 31, 2026
87 checks passed
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.

v1 entrypoint modules break dagger generate

2 participants