{"record":{"id":"33917f3dc391008a","repo":"multica-ai/multica","slug":"extract-binary-w","errorCode":null,"errorMessage":"extract binary: %w","messagePattern":"extract binary: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/internal/cli/update.go","lineNumber":442,"sourceCode":"\t\t// corrupted asset is rare enough that retrying through the same\n\t\t// CDN is the right default; persistent failures will surface in\n\t\t// the daemon log.\n\t\treturn \"\", fmt.Errorf(\"verify download: %w\", err)\n\t}\n\n\t// Extract the binary from the archive.\n\tbinaryName := \"multica\"\n\tif runtime.GOOS == \"windows\" {\n\t\tbinaryName = \"multica.exe\"\n\t}\n\tvar binaryData []byte\n\tif runtime.GOOS == \"windows\" {\n\t\tbinaryData, err = extractBinaryFromZip(bytes.NewReader(archiveData), binaryName)\n\t} else {\n\t\tbinaryData, err = extractBinaryFromTarGz(bytes.NewReader(archiveData), binaryName)\n\t}\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"extract binary: %w\", err)\n\t}\n\n\t// Atomic replace: write to temp file, then rename over the original.\n\tdir := filepath.Dir(exePath)\n\ttmpFile, err := os.CreateTemp(dir, \"multica-update-*\")\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"create temp file: %w\", err)\n\t}\n\ttmpPath := tmpFile.Name()\n\n\tif _, err := tmpFile.Write(binaryData); err != nil {\n\t\ttmpFile.Close()\n\t\tos.Remove(tmpPath)\n\t\treturn \"\", fmt.Errorf(\"write temp file: %w\", err)\n\t}\n\ttmpFile.Close()\n\n\t// Preserve original file permissions.","sourceCodeStart":424,"sourceCodeEnd":460,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/internal/cli/update.go#L424-L460","documentation":"After verification, the archive is unpacked via extractBinaryFromZip (Windows) or extractBinaryFromTarGz (others) looking for the 'multica'/'multica.exe' entry; any failure is wrapped as 'extract binary: %w'. Because the SHA-256 already matched the manifest, extraction errors almost always mean the archive layout changed rather than corruption.","triggerScenarios":"The binary inside the archive was renamed or nested in a way that no longer matches filepath.Base(hdr.Name) == \"multica\"; the archive format for a platform switched (zip vs tar.gz) without updating releaseArchiveExtension; the checksum passed but the archive is a format Go's archive/* readers reject.","commonSituations":"GoReleaser name_template changes that renamed the inner binary; a release built by a fork with a different layout; new platform targets whose packaging differs.","solutions":["Download the asset and list its contents (tar -tzf / unzip -l) to see the actual binary name and layout.","Align the expected binaryName (\"multica\"/\"multica.exe\") and archive extension with the release configuration in .goreleaser.yml.","Check the wrapped message to distinguish 'binary not found' (layout) from 'gzip reader'/'read tar' (format).","Re-release with the expected layout or fix the extractor to match the new one."],"exampleFix":"null","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"out, err := cli.UpdateViaDownload(ver)\nif err != nil {\n    msg := err.Error()\n    switch {\n    case strings.HasPrefix(msg, \"extract binary: binary \"):\n        // layout change: inspect archive listing, fix name_template\n    case strings.HasPrefix(msg, \"extract binary: gzip reader\"):\n        // format mismatch: asset is not gzip despite .tar.gz name\n    }\n}","preventionTips":["Pin the inner binary name to 'multica' in release config","Test one full self-update per platform per release in CI","Keep releaseArchiveExtension in sync with actual packaging"],"tags":["archive","extraction","tar","zip","release"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}