From eabac66663084db6e3db5ef667733df243449896 Mon Sep 17 00:00:00 2001 From: agrasth Date: Tue, 25 Aug 2026 14:36:13 +0530 Subject: [PATCH 1/2] Retry GetBuildInfo to absorb Artifactory index propagation lag pm-version-monitor's pnpm compatibility runs showed a sharp, date-correlated pass-rate collapse (100% -> ~25%) on days with heavy concurrent CI load, spread across every pnpm line including the officially-supported 10.x baseline -- not correlated with pnpm version at all. Root cause traced to every failure sharing the same signature: Error: Should be true Messages: Build info was not found tests.GetBuildInfo queried Artifactory immediately after artifactoryCli.Exec("bp", ...) reported success, with no retry. BuildInfoService.GetBuildInfo's own doc comment says a 404 surfaces as (found=false, err=nil) -- exactly the shape of a build that was published but whose search index entry hasn't propagated yet, which happens more often under concurrent load hitting the same instance. Add a short bounded retry (4 attempts, 500ms exponential backoff, ~7.5s worst case) inside GetBuildInfo itself so every one of its ~20 call sites across pnpm_test.go, npm_test.go, maven_test.go, etc. benefits without individual changes. Only the found=false/err=nil case retries; any real error still returns immediately, unchanged from before. --- utils/tests/utils.go | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/utils/tests/utils.go b/utils/tests/utils.go index 8cb6ad99e..276507045 100644 --- a/utils/tests/utils.go +++ b/utils/tests/utils.go @@ -283,7 +283,24 @@ func DeleteFiles(deleteSpec *spec.SpecFiles, serverDetails *config.ServerDetails return deleteCommand.DeleteFiles(reader) } +// buildInfoIndexRetries and buildInfoIndexBackoff bound the retry in +// GetBuildInfo below: Artifactory's build-info search index can lag a +// freshly-published build by a second or two, especially under concurrent +// CI load (many PM compatibility tests hitting the same instance at once). +// Total worst-case wait is ~7.5s (0.5+1+2+4), which is negligible next to +// the seconds a full PM test takes, but eliminates a whole class of +// "Build info was not found" false failures immediately after a publish. +const ( + buildInfoIndexRetries = 4 + buildInfoIndexBackoff = 500 * time.Millisecond +) + // This function makes no assertion, caller is responsible to assert as needed. +// +// Retries when the build info is genuinely not there yet (found=false, +// err=nil is Artifactory's 404 signal — see BuildInfoService.GetBuildInfo) +// to absorb search-index propagation lag right after a publish. Any real +// error is returned immediately, unretried, exactly as before. func GetBuildInfo(serverDetails *config.ServerDetails, buildName, buildNumber string) (pbi *buildinfo.PublishedBuildInfo, found bool, err error) { servicesManager, err := artUtils.CreateServiceManager(serverDetails, -1, 0, false) if err != nil { @@ -292,7 +309,16 @@ func GetBuildInfo(serverDetails *config.ServerDetails, buildName, buildNumber st params := services.NewBuildInfoParams() params.BuildName = buildName params.BuildNumber = buildNumber - return servicesManager.GetBuildInfo(params) + + wait := buildInfoIndexBackoff + for attempt := 0; ; attempt++ { + pbi, found, err = servicesManager.GetBuildInfo(params) + if err != nil || found || attempt == buildInfoIndexRetries { + return pbi, found, err + } + time.Sleep(wait) + wait *= 2 + } } func GetBuildRuns(serverDetails *config.ServerDetails, buildName string) (pbi *buildinfo.BuildRuns, found bool, err error) { From 6e10efba45f44eef7b609b38b0799e638343abd5 Mon Sep 17 00:00:00 2001 From: agrasth Date: Tue, 25 Aug 2026 14:55:28 +0530 Subject: [PATCH 2/2] Fix CI lint: migrate reverse-proxy test helper off deprecated Director golangci-lint (staticcheck SA1019) started failing on this PR's CI run because master recently bumped to Go 1.26, which deprecates httputil.ReverseProxy.Director in favor of Rewrite (available since Go 1.20). Unrelated to the npm fixture change in this PR, but it blocks the CI gate regardless, so fixing it here. Direct translation: Rewrite receives a *httputil.ProxyRequest whose .Out field is a pre-cloned copy of the incoming request, so the closure only needs to set the same three fields Director set directly on the request (Host, URL.Host, URL.Scheme). Defining a custom Rewrite func means none of the automatic default behavior (X-Forwarded-For, etc.) kicks in, matching Director's original no-defaults behavior exactly -- this is a mechanical migration with no functional change. Verified with the exact CI lint invocation (golangci-lint 2.13.1, same flag set) against both the changed package and the full repo: 0 issues. --- utils/tests/proxy/server/server.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/utils/tests/proxy/server/server.go b/utils/tests/proxy/server/server.go index 40a3a5fe6..81757892a 100644 --- a/utils/tests/proxy/server/server.go +++ b/utils/tests/proxy/server/server.go @@ -47,16 +47,21 @@ func getReverseProxyHandler(targetUrl string) (*httputil.ReverseProxy, error) { return nil, err } origHost := target.Host - d := func(req *http.Request) { - req.URL.Host = origHost - req.Host = origHost - req.URL.Scheme = target.Scheme + // Rewrite replaces the deprecated Director (Go 1.26, staticcheck SA1019). + // pr.Out is a clone of pr.In that ReverseProxy sends upstream; unlike a + // nil Rewrite's defaults, defining this func means no other header + // rewriting happens automatically (X-Forwarded-For, etc.) -- matching + // Director's behavior exactly, since Director never set defaults either. + rewrite := func(pr *httputil.ProxyRequest) { + pr.Out.URL.Host = origHost + pr.Out.Host = origHost + pr.Out.URL.Scheme = target.Scheme } tr := &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, } proxyErrLogger := log.New(os.Stdout, "PROXY-LOGGER", log.Ldate|log.Ltime|log.Lshortfile) - p := &httputil.ReverseProxy{Director: d, Transport: tr, ErrorLog: proxyErrLogger} + p := &httputil.ReverseProxy{Rewrite: rewrite, Transport: tr, ErrorLog: proxyErrLogger} return p, nil }