dagger/dagger · error

module config is required

Error message

module config is required

What it means

legacyModuleConfigAsCurrent requires a non-nil *modules.ModuleConfig to convert a legacy module config into the current serialization format. This error means the conversion was invoked with a nil config pointer.

Source

Thrown at core/schema/workspace_migrate_module_config.go:84

	if len(conversions) == 0 {
		return nil, nil
	}
	return conversions, nil
}

// workspaceMigrationLeavesModuleLegacy reports whether migration leaves this
// module's config in legacy format: a discovered nested workspace (own
// toolchains/blueprint) is neither converted in place nor routed through
// PlanMigration.
func workspaceMigrationLeavesModuleLegacy(compatWorkspace *workspace.CompatWorkspace) bool {
	return compatWorkspace.DiscoveredLocalModule &&
		workspace.HasOwnWorkspaceSemantics(compatWorkspace.Config)
}

func legacyModuleConfigAsCurrent(cfg *modules.ModuleConfig) ([]byte, error) {
	if cfg == nil {
		return nil, fmt.Errorf("module config is required")
	}
	cloned := *cfg
	if cloned.Source == "." {
		cloned.Source = ""
	}
	return modules.MarshalModuleConfigForFormat(&modules.ModuleConfigWithUserFields{
		ModuleConfig: cloned,
	}, modules.ConfigFormatCurrent)
}

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Ensure compatWorkspace.Config is loaded (non-nil) before the conversion step
  2. Re-run legacy config loading and propagate any load error instead of continuing with nil
  3. Fix the source legacy config file so it parses into a ModuleConfig

Example fix

// before
if compat.Config == nil { /* conversion still attempted */ }
// after
if compat.Config == nil {
    return nil, fmt.Errorf("config %s not loaded", compat.ConfigPath)
}
Defensive patterns

Strategy: type-guard

Validate before calling

if cfg == nil {
    return fmt.Errorf("refusing conversion: module config is nil")
}

Type guard

func isModuleConfig(cfg *modules.ModuleConfig) bool { return cfg != nil }

Try / catch

data, err := legacyModuleConfigAsCurrent(cfg)
if err != nil {
    if strings.Contains(err.Error(), "module config is required") {
        return fmt.Errorf("reload the legacy config; got nil: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: workspaceMigrationModuleConfigConversions processing a compat workspace whose Config field is nil (config was never loaded or failed to load silently).

Common situations: Legacy config file missing or unparseable so loading produced a nil config; partially constructed CompatWorkspace in tooling; test fixtures omitting Config.

Related errors


AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05). Data as JSON: /api/errors/6c88cba9521370b5. Report an issue: GitHub.