dagger/dagger · error
failed to get module source id: %w
Error message
failed to get module source id: %w
What it means
GenerateClient fetches modSource.ID(ctx) to obtain a stable content-addressed identifier of the module source, which is passed into the LibGenerator for generating the client bindings. If that Dagger API call fails, the error is wrapped as "failed to get module source id". It means the engine could not resolve the ModuleSource into an ID — usually an engine-side problem with the source context.
Source
Thrown at sdk/typescript/runtime/main.go:177
}
}
// Returns a directory with a standalone generated client and any necessary configuration
// files that are required to work.
func (t *TypescriptSdk) GenerateClient(
ctx context.Context,
modSource *dagger.ModuleSource,
introspectionJSON *dagger.File,
outputDir string,
) (*dagger.Directory, error) {
cfg, err := analyzeClientConfig(ctx, modSource)
if err != nil {
return nil, fmt.Errorf("failed to analyze module config: %w", err)
}
moduleSourceID, err := modSource.ID(ctx)
if err != nil {
return nil, fmt.Errorf("failed to get module source id: %w", err)
}
result := dag.Directory()
libGenerator := NewLibGenerator(t.SDKSourceDir, &LibGeneratorOpts{
moduleSourceID: string(moduleSourceID),
genClient: true,
coexistWithModule: cfg.sdk != "" && cfg.subPath == ".",
})
if cfg.sdkLibOrigin == Remote {
// Include every generated binding: client.gen.ts plus the per-dependency
// <dep>.gen.ts files it imports via relative "./<dep>.gen.js" paths.
result = result.WithDirectory(
outputDir,
libGenerator.GenerateRemoteLibrary(introspectionJSON, outputDir),
dagger.DirectoryWithDirectoryOpts{
Include: []string{"*.gen.ts"},View on GitHub (pinned to 82ba2681db)
Solutions
- Re-run the generation command; many causes are transient.
- Run with `dagger --debug` to see the underlying engine error.
- If the source is a remote git ref, verify it is reachable and the commit/ref exists locally.
- Restart the Dagger engine (`dagger engine stop` then retry) if errors persist.
Defensive patterns
Strategy: retry
Validate before calling
// Ensure the module source context resolves locally before generation:
if (isRemoteGitSource) { run('git ls-remote ' + url + ' ' + ref) } // verifies ref is reachable
git status --porcelain // verify clean, resolvable working tree Try / catch
moduleSourceID, err := modSource.ID(ctx)
if err != nil {
return nil, fmt.Errorf("failed to get module source id: %w", err) // retry transient engine failures
} Prevention
- Retry the generation command once on failure.
- For remote git sources, verify the ref/commit is reachable.
- Restart the engine if ID resolution fails repeatedly.
- Keep large binaries/untracked noise out of the module context.
When it happens
Trigger: Calling GenerateClient when ModuleSource.ID(ctx) errors: the source context directory is unavailable, engine evaluation of the source fails, or the session/context is cancelled mid-call.
Common situations: Running client generation against a module whose git/context directory cannot be resolved by the engine (e.g. dirty git state with unresolved refs, remote git source fetch failures, or engine storage issues).
Related errors
- failed to check if src dir exists: %w
- failed to list source files: %w
- failed to create or update tsconfig.json
- failed to update package.json: %w
- failed to update deno.json
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/ae3fa6b848ad83bd.
Report an issue: GitHub.