{"record":{"id":"7ee151517cac14c1","repo":"github/copilot-sdk","slug":"existing-s-hash-mismatch","errorCode":null,"errorMessage":"existing %s hash mismatch","messagePattern":"existing (.+?) hash mismatch","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/internal/embeddedcli/embeddedcli.go","lineNumber":451,"sourceCode":"\tnodePath := filepath.Join(installDir, \"runtime.node\")\n\tif err := installVerifiedFile(nodePath, config.RuntimeNode, config.RuntimeNodeHash, 0644, \"runtime.node\"); err != nil {\n\t\treturn \"\", err\n\t}\n\twrapperPath := filepath.Join(installDir, runtimeExecutableName())\n\tif err := installVerifiedFile(wrapperPath, config.RuntimeExecutable, config.RuntimeExecutableHash, 0755, \"runtime wrapper\"); err != nil {\n\t\treturn \"\", err\n\t}\n\treturn wrapperPath, nil\n}\n\nfunc installVerifiedFile(path string, reader io.Reader, expectedHash []byte, mode os.FileMode, label string) error {\n\tif _, err := os.Stat(path); err == nil {\n\t\texistingHash, err := hashFile(path)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"hashing existing %s: %w\", label, err)\n\t\t}\n\t\tif !bytes.Equal(existingHash, expectedHash) {\n\t\t\treturn fmt.Errorf(\"existing %s hash mismatch\", label)\n\t\t}\n\t\tif runtime.GOOS != \"windows\" && mode.Perm()&0111 != 0 {\n\t\t\tinfo, err := os.Stat(path)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"checking existing %s permissions: %w\", label, err)\n\t\t\t}\n\t\t\tif info.Mode().Perm()&0111 == 0 {\n\t\t\t\tif err := os.Chmod(path, info.Mode().Perm()|mode.Perm()&0111); err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"restoring existing %s permissions: %w\", label, err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n\n\ttmp, err := os.CreateTemp(filepath.Dir(path), \".copilot-runtime-pair-*.tmp\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"creating temporary %s: %w\", label, err)","sourceCodeStart":433,"sourceCodeEnd":469,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/internal/embeddedcli/embeddedcli.go#L433-L469","documentation":"installVerifiedFile refuses to overwrite an existing file whose SHA-256 hash differs from the hash of the content about to be installed. This guards against clobbering a modified or foreign binary with embedded assets. The message includes the asset label (e.g. \"runtime asset\").","triggerScenarios":"The file at path exists and hashFile succeeds, but bytes.Equal(existingHash, expectedHash) is false during any call from installRuntimeAssets/installRuntimePair — i.e. the on-disk file differs from the embedded content.","commonSituations":"A user or patch script edited the installed binary, a different library version was previously installed into the same directory, or the file was partially written by a failed earlier install.","solutions":["Delete the modified file at the target path and re-run the install so the verified embedded version is written.","Check which version originally installed the file; align install directories per version if you need multiple versions.","If the modification is intentional, stop installing over that path — point installDir at a dedicated directory."],"exampleFix":"// before\nclient.InstallAt(\"/opt/shared/cli\") // contains a patched binary\n// after\nos.Remove(\"/opt/shared/cli/cli-server\")\nclient.InstallAt(\"/opt/shared/cli\")","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := client.InstallAt(dir); err != nil {\n    if strings.Contains(err.Error(), \"hash mismatch\") {\n        // file was modified on disk; prompt user to delete it and reinstall\n    }\n}","preventionTips":["Never hand-edit installed runtime binaries","Use one install directory per library version","Reinstall after manual modifications"],"tags":["checksum","integrity","install"],"backgroundTag":"checksum-mismatch","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}