{"record":{"id":"2c0269b86ce965ad","repo":"dagger/dagger","slug":"encode-workspace-config-w","errorCode":null,"errorMessage":"encode workspace config: %w","messagePattern":"encode workspace config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/modtree.go","lineNumber":567,"sourceCode":"\tif mod.LegacyDefaultPath {\n\t\tquery = query.Arg(\"legacyDefaultPath\", true)\n\t}\n\tif mod.ContextSource.Valid {\n\t\tcontextSrc := mod.ContextSource.Value.Self()\n\t\tif contextSrc != nil {\n\t\t\tcontextRef := contextSrc.AsString()\n\t\t\tif contextRef != \"\" && (contextRef != modSrc.AsString() || contextSrc.Pin() != modSrc.Pin()) {\n\t\t\t\tquery = query.Arg(\"defaultPathContextSourceRef\", contextRef)\n\t\t\t\tif contextPin := contextSrc.Pin(); contextPin != \"\" {\n\t\t\t\t\tquery = query.Arg(\"defaultPathContextSourcePin\", contextPin)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif len(mod.WorkspaceConfig) > 0 {\n\t\tworkspaceConfigJSON, err := json.Marshal(mod.WorkspaceConfig)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"encode workspace config: %w\", err)\n\t\t}\n\t\tquery = query.Arg(\"legacyWorkspaceConfigJson\", string(workspaceConfigJSON))\n\t\tif mod.DefaultsFromDotEnv {\n\t\t\tquery = query.Arg(\"legacyDefaultsFromDotEnv\", true)\n\t\t}\n\t}\n\tif len(mod.LegacyArgCustomizations) > 0 {\n\t\tcustomizationsJSON, err := json.Marshal(mod.LegacyArgCustomizations)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"encode arg customizations: %w\", err)\n\t\t}\n\t\tquery = query.Arg(\"legacyArgCustomizationsJson\", string(customizationsJSON))\n\t}\n\treturn query, nil\n}\n\n// Initialize a standalone dagql server for querying the given module\nfunc dagqlServerForModule(ctx context.Context, mod dagql.ObjectResult[*Module]) (*dagql.Server, error) {","sourceCodeStart":549,"sourceCodeEnd":585,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/modtree.go#L549-L585","documentation":"When the module carries a WorkspaceConfig, buildScaleOutModuleQuery marshals it to JSON to pass as legacyWorkspaceConfigJson to the asModule selection. This error wraps a json.Marshal failure on the workspace config, meaning the config structure contains values that cannot be serialized to JSON.","triggerScenarios":"Scale-out module load where mod.WorkspaceConfig is non-empty and json.Marshal(mod.WorkspaceConfig) fails — e.g. unsupported types (channels, funcs, cycles) somehow present in the config map, or NaN/invalid values.","commonSituations":"Rare in practice since WorkspaceConfig comes from decoded JSON; can occur with programmatically constructed Module objects containing non-JSON-serializable fields, or custom marshaler errors on the config type.","solutions":["Inspect the wrapped marshal error to find the offending field in the workspace config.","Ensure the Module object was built from decoded JSON config (dagger.json) rather than hand-populated structures.","Validate dagger.json workspace section parses cleanly before running scale-out commands.","Report/upgrade if triggered by valid config — indicates a marshaling regression."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// sanity-check the workspace config parses as JSON before module load\nconst cfg = JSON.parse(fs.readFileSync('dagger.json', 'utf8'));\nif (cfg.workspace) JSON.stringify(cfg.workspace); // throws early on bad shapes","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only populate WorkspaceConfig from decoded JSON, never hand-built structures.","Validate dagger.json with a schema/linter in CI.","Update tooling together so config types stay marshalable."],"tags":["dagger","json","workspace-config","scale-out"],"backgroundTag":"json-marshal-failed","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}