{"record":{"id":"7e4fe40a9f81dbdc","repo":"golang/go","slug":"marshal-embedcfg-v","errorCode":null,"errorMessage":"marshal embedcfg: %v","messagePattern":"marshal embedcfg: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/work/exec.go","lineNumber":832,"sourceCode":"\t\tfmt.Fprintf(&icfg, \"packagefile %s=%s\\n\", p1.ImportPath, a1.built)\n\t}\n\n\t// Prepare Go embed config if needed.\n\t// Unlike the import config, it's okay for the embed config to be empty.\n\tvar embedcfg []byte\n\tif len(p.Internal.Embed) > 0 {\n\t\tvar embed struct {\n\t\t\tPatterns map[string][]string\n\t\t\tFiles    map[string]string\n\t\t}\n\t\tembed.Patterns = p.Internal.Embed\n\t\tembed.Files = make(map[string]string)\n\t\tfor _, file := range p.EmbedFiles {\n\t\t\tembed.Files[file] = fsys.Actual(filepath.Join(p.Dir, file))\n\t\t}\n\t\tjs, err := json.MarshalIndent(&embed, \"\", \"\\t\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"marshal embedcfg: %v\", err)\n\t\t}\n\t\tembedcfg = js\n\t}\n\n\t// Find PGO profile if needed.\n\tvar pgoProfile string\n\tfor _, a1 := range a.Deps {\n\t\tif a1.Mode != \"preprocess PGO profile\" {\n\t\t\tcontinue\n\t\t}\n\t\tif pgoProfile != \"\" {\n\t\t\treturn fmt.Errorf(\"action contains multiple PGO profile dependencies\")\n\t\t}\n\t\tpgoProfile = a1.built\n\t}\n\n\tvar coverageConfig string\n\tif coverPr != nil {","sourceCodeStart":814,"sourceCodeEnd":850,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/work/exec.go#L814-L850","documentation":"Thrown during the Go build when the toolchain JSON-encodes the embed configuration (the resolved //go:embed patterns and files) that gets passed to the compiler. The marshaled struct holds only map[string][]string and map[string]string fields, both always JSON-safe, so this is a defensive check for an effectively-impossible internal condition. Reaching it signals a corrupted toolchain or memory fault rather than a user mistake.","triggerScenarios":"Fires in (b *Builder).build at the json.MarshalIndent(&embed,...) call, only when a package has //go:embed directives (len(p.Internal.Embed) > 0) and the marshal of the embed{Patterns,Files} struct returns a non-nil error.","commonSituations":"A corrupted or forked go binary, memory corruption, or an exotic toolchain modification. Not reachable through normal //go:embed usage, since the data types involved are always serializable.","solutions":["Reinstall or upgrade the Go toolchain to rule out a corrupted binary","Run `go env` and confirm a standard GOROOT/GOTOOLCHAIN","Report a bug to the Go project with the full build log and the package's //go:embed directives if reproducible"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the Go toolchain updated and from an official source","Run `go version` and `go env GOROOT` to detect a corrupted or forked toolchain","Validate //go:embed patterns with `go list -e -json <pkg>` before building"],"tags":["go-toolchain","embed","json-marshal","internal-error"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}