{"record":{"id":"87a6462f9c2c8a59","repo":"BoundaryML/baml","slug":"failed-copying-from-s-to-s-w","errorCode":null,"errorMessage":"failed copying from %s to %s: %w","messagePattern":"failed copying from (.+?) to (.+?): %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/baml_go/lib_common.go","lineNumber":655,"sourceCode":"\tif err != nil {\n\t\treturn fmt.Errorf(\"failed open source %s: %w\", src, err)\n\t}\n\tdefer source.Close()\n\n\tdestination, err := os.Create(dst)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed create destination %s: %w\", dst, err)\n\t}\n\tdefer func() {\n\t\tcerr := destination.Close()\n\t\tif err == nil && cerr != nil {\n\t\t\terr = fmt.Errorf(\"failed close destination %s: %w\", dst, cerr)\n\t\t}\n\t}()\n\n\t_, err = io.Copy(destination, source)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed copying from %s to %s: %w\", src, dst, err)\n\t}\n\n\terr = destination.Sync()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed syncing destination %s: %w\", dst, err)\n\t}\n\n\tlogger.Debug(\"File copied successfully\", \"source\", src, \"destination\", dst)\n\treturn nil\n}\n\nfunc isSupportedPlatform() bool {\n\tosOk := runtime.GOOS == \"darwin\" || runtime.GOOS == \"linux\" || runtime.GOOS == \"windows\"\n\tarchOk := runtime.GOARCH == \"amd64\" || runtime.GOARCH == \"arm64\"\n\treturn osOk && archOk\n}\n\nfunc initSlog() {","sourceCodeStart":637,"sourceCodeEnd":673,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/baml_go/lib_common.go#L637-L673","documentation":"copyFile (called by downloadBamlLibrary) wraps io.Copy failures with this message, indicating the byte transfer from the source (downloaded artifact) to the destination file failed partway. The %w preserves the underlying read/write error.","triggerScenarios":"io.Copy returns non-nil: source read fails (source file removed/truncated mid-copy) or destination write fails (disk full, I/O error) while copying the BAML native library artifact.","commonSituations":"Disk filling up during first-run native library download; concurrent processes writing the same temp file; antivirus or container storage issues interrupting writes.","solutions":["Free disk space on the destination volume and retry","Ensure only one process is performing the download/copy at a time (avoid concurrent builds sharing the cache)","Check for antivirus/quarantine tools interfering with the destination path","Delete the partial destination file and re-trigger downloadBamlLibrary"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if fi, err := os.Stat(src); err != nil || fi.Size() == 0 {\n    return fmt.Errorf(\"source artifact missing or empty\")\n}","typeGuard":null,"tryCatchPattern":"for attempt := 0; attempt < 3; attempt++ {\n    err := baml.DownloadLibrary(dst)\n    if err == nil || !strings.Contains(err.Error(), \"failed copying\") {\n        return err\n    }\n    time.Sleep(backoff(attempt))\n}","preventionTips":["Ensure adequate free disk space before downloads","Serialize downloads across concurrent processes/CI jobs (file lock)","Exclude the cache directory from antivirus real-time scanning"],"tags":["go","file-io","io-copy","native-library-download"],"backgroundTag":"file-write-failed","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}