{"record":{"id":"bccafc3b808fa04a","repo":"JanDeDobbeleer/oh-my-posh","slug":"s-is-not-a-valid-zip-file","errorCode":null,"errorMessage":"%s is not a valid zip file","messagePattern":"(.+?) is not a valid zip file","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/font/download.go","lineNumber":40,"sourceCode":"\tif zipPath, OK := cache.Device.Get[string](fontURL); OK {\n\t\tif b, err := os.ReadFile(zipPath); err == nil {\n\t\t\treturn b, nil\n\t\t}\n\t}\n\n\t// validate if we have a local file\n\tu, err := url.Parse(fontURL)\n\tif err != nil || u.Scheme != \"https\" {\n\t\treturn nil, errors.New(\"font path must be a valid URL\")\n\t}\n\n\tvar b []byte\n\tif b, err = getRemoteFile(fontURL, report); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif !isZipFile(b) {\n\t\treturn nil, fmt.Errorf(\"%s is not a valid zip file\", fontURL)\n\t}\n\n\tfileName := path.Base(fontURL)\n\n\tzipPath := filepath.Join(os.TempDir(), fileName)\n\ttempFile, err := os.Create(zipPath)\n\tdefer func() {\n\t\t_ = tempFile.Close()\n\t}()\n\n\tif err != nil {\n\t\treturn b, nil\n\t}\n\n\t_, err = tempFile.Write(b)\n\tif err != nil {\n\t\treturn b, nil\n\t}","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/cli/font/download.go#L22-L58","documentation":"oh-my-posh's font downloader (`oh-my-posh font download <name>`) fetches a font archive from a remote URL and validates it is a ZIP before extracting. This error means the bytes downloaded from `fontURL` failed the ZIP magic-number check (`isZipFile`), so the installer refuses to process the payload. It guards against HTML error pages, redirects to login pages, or corrupted transfers being treated as font archives.","triggerScenarios":"`download(fontURL, report)` calls `getRemoteFile` successfully (HTTP 200) but the response body does not start with the ZIP signature (PK). Typical when the URL points to an HTML page instead of the archive, a CDN/proxy returns an error or captcha page with status 200, or the file is a .tar.gz instead of a .zip.","commonSituations":"GitHub codeload URL changed or redirected to an HTML page; corporate proxy/SSL-inspection appliance substituting a block page; manually specified URL for a release asset that is actually a tarball; truncated download served with 200 OK.","solutions":["Verify the URL returns a real .zip: `curl -sIL <url>` and check Content-Type (application/zip) and size","Re-run the command — a transient proxy/cache issue may have served a bad body","Use an official release asset URL (e.g. a Nerd Fonts release zip) rather than a repo page URL","Check for corporate proxy interference (set HTTP(S)_PROXY correctly or bypass it)","If persistent, report the URL at github.com/JanDeDobbeleer/oh-my-posh/issues"],"exampleFix":"// before: URL to an HTML release page\noh-my-posh font download \"https://github.com/ryanoasis/nerd-fonts/releases\"\n// after: URL to the actual zip asset\noh-my-posh font download \"https://github.com/ryanoasis/nerd-fonts/releases/download/v3.2.1/FiraCode.zip\"","handlingStrategy":"validation","validationCode":"func isZip(path string) error {\n\tf, err := os.Open(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\tmagic := make([]byte, 2)\n\tif _, err := io.ReadFull(f, magic); err != nil {\n\t\treturn err\n\t}\n\tif magic[0] != 'P' || magic[1] != 'K' {\n\t\treturn fmt.Errorf(\"%s is not a zip file\", path)\n\t}\n\treturn nil\n}\n// run isZip() on the URL's payload (or curl -sI and check Content-Type: application/zip) before installing","typeGuard":null,"tryCatchPattern":"if err := fontDownload(url); err != nil {\n\tif strings.Contains(err.Error(), \"is not a valid zip file\") {\n\t\t// inspect URL / retry with the canonical release asset URL\n\t}\n}","preventionTips":["Only pass direct URLs to .zip release assets, never HTML release pages","Check Content-Type is application/zip before trusting a 200 response","Beware proxies/CDNs that return 200 with an HTML block page"],"tags":["download","zip","network"],"backgroundTag":"invalid-zip-file","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}