{"record":{"id":"59408f684d763d88","repo":"golang/go","slug":"object-is-s-expected-s","errorCode":null,"errorMessage":"object is [%s] expected [%s]","messagePattern":"object is \\[(.+?)\\] expected \\[(.+?)\\]","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/compile/internal/noder/import.go","lineNumber":248,"sourceCode":"}\n\n// readExportData returns the contents of GC-created unified export data.\nfunc readExportData(f *os.File) (data string, err error) {\n\tr := bio.NewReader(f)\n\n\tsz, err := exportdata.FindPackageDefinition(r.Reader)\n\tif err != nil {\n\t\treturn\n\t}\n\tend := r.Offset() + int64(sz)\n\n\tabihdr, _, err := exportdata.ReadObjectHeaders(r.Reader)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif expect := objabi.HeaderString(); abihdr != expect {\n\t\terr = fmt.Errorf(\"object is [%s] expected [%s]\", abihdr, expect)\n\t\treturn\n\t}\n\n\t_, err = exportdata.ReadExportDataHeader(r.Reader)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tpos := r.Offset()\n\n\t// Map export data section (+ end-of-section marker) into memory\n\t// as a single large string. This reduces heap fragmentation and\n\t// allows returning individual substrings very efficiently.\n\tvar mapped string\n\tmapped, err = base.MapFile(r.File(), pos, end-pos)\n\tif err != nil {\n\t\treturn\n\t}","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/compile/internal/noder/import.go#L230-L266","documentation":"Returned when the object-file ABI header read from an export-data blob does not match the ABI header the running compiler expects (objabi.HeaderString()). It is a hard version gate: the object was produced by a compiler using a different object/ABI format and cannot be consumed.","triggerScenarios":"exportdata.ReadObjectHeaders returns abihdr that differs from objabi.HeaderString(); the comparison at import.go:251 fails and the message reports both the found and expected headers.","commonSituations":"Mixing object files between Go major versions (e.g. 1.21 objects read by 1.22), a stale build cache from a previous toolchain, or a hand-built -importcfg referencing objects from another Go tree.","solutions":["go clean -cache to remove objects with mismatched ABI headers.","Ensure GOROOT and GOTOOLCHAIN point to the same Go version used to build the dependencies (go version, go env GOROOT GOTOOLCHAIN).","Rebuild all dependencies from source with the current toolchain (go build -a ./...).","Remove stale vendored .a files or third-party caches."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Reject build inputs whose object ABI cannot match this compiler.\nif !bytes.HasPrefix(objBytes, []byte(objabi.HeaderString())) {\n    return errors.New(\"object ABI mismatch; rebuild with current toolchain\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build the entire closure with one Go version.","Pin GOTOOLCHAIN in go.mod for reproducible ABI."],"tags":["go-compiler","abi","toolchain-mismatch","object-files"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}