{"record":{"id":"244128cbea28a036","repo":"apache/beam","slug":"failed-to-connect-to-v-received-non-200-response-code-got-v","errorCode":null,"errorMessage":"failed to connect to %v: received non 200 response code, got %v","messagePattern":"failed to connect to (.+?): received non 200 response code, got (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go","lineNumber":126,"sourceCode":"\t}\n\n\t// Issue warning when downloading from public repositories\n\tif strings.Contains(url, \"repo.maven.apache.org\") ||\n\t\tstrings.Contains(url, \"repo1.maven.org\") ||\n\t\tstrings.Contains(url, \"maven.google.com\") ||\n\t\tstrings.Contains(url, \"maven-central.storage-download.googleapis.com\") {\n\t\tlog.Printf(\"WARNING: Downloading JAR file from public repository: %s. \"+\n\t\t\t\"This may pose security risks or cause instability due to repository availability. Consider pre-staging dependencies or using private mirrors.\", url)\n\t}\n\n\tresp, err := http.Get(string(url))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != 200 {\n\t\treturn \"\", fmt.Errorf(\"failed to connect to %v: received non 200 response code, got %v\", url, resp.StatusCode)\n\t}\n\n\tfile, err := os.Create(jarPath)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error in creating jar %s: %w\", jarPath, err)\n\t}\n\n\t_, err = io.Copy(file, resp.Body)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error in coping file %s inside jar %s: %w\", file.Name(), jarPath, err)\n\t}\n\n\treturn jarPath, nil\n}\n\nfunc validatePath(dest, filename string) (string, error) {\n\tdestPath := filepath.Join(dest, filename)\n\tcleanDest := filepath.Clean(dest)","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go#L108-L144","documentation":"getLocalJar downloads the Java expansion service jar over HTTP and requires HTTP 200. Any other status (403, 404, 5xx, redirect handled as 3xx) aborts the download with this error before the jar file is created. It exists to fail fast with a clear message instead of writing an HTML error page into a .jar file.","triggerScenarios":"getLocalJar (via MakeJar) performs http.Get(url) and resp.StatusCode != 200 — a bad or moved jar URL, auth-protected artifact repository, or server outage.","commonSituations":"Artifact repository requires credentials so the CDN returns 403; jar was published under a new Beam version so the pinned URL 404s; corporate proxy blocks the download; transient 502/503 from the artifact host.","solutions":["Print/verify the exact URL and open it in a browser or `curl -I` to see the real status code.","If 404: update the Beam version or jar URL to the published artifact location.","If 403: add authentication to the artifact repository or use a mirror you can access.","If 5xx: retry later or pre-download the jar locally and point the pipeline at the local copy."],"exampleFix":"// before\n// jar auto-downloaded from a pinned, now-dead URL\n// after: pre-download or verify availability\nresp, _ := http.Head(jarURL)\nif resp == nil || resp.StatusCode != 200 {\n    log.Fatalf(\"jar not reachable (%s): status %v\", jarURL, resp.StatusCode)\n}","handlingStrategy":"validation","validationCode":"resp, err := http.Head(url)\nif err != nil || resp.StatusCode != 200 {\n    return fmt.Errorf(\"jar URL %s not reachable (status %v)\", url, resp.StatusCode)\n}","typeGuard":null,"tryCatchPattern":"jarPath, err := expansionx.MakeJar(ctx, url, dest)\nif err != nil && strings.Contains(err.Error(), \"non 200 response code\") {\n    // fall back to mirror URL or pre-downloaded local jar\n    jarPath, err = expansionx.MakeJar(ctx, mirrorURL, dest)\n}","preventionTips":["curl -I the jar URL during environment setup to catch 403/404 early.","Pin jar URLs to versions you control or host the jar in an internal mirror.","Check Beam release notes for artifact relocation when upgrading versions.","Add proxy/auth configuration for artifact repositories in corporate environments."],"tags":["go","http","download","network"],"backgroundTag":"http-non-200-response","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}