From ee7e1cc6b261b3076e7f94b9f77eb4b2b07dd605 Mon Sep 17 00:00:00 2001 From: Jake Coffman Date: Wed, 23 Sep 2026 11:04:38 -0500 Subject: [PATCH] pass the job_id to the proxy too --- internal/infra/proxy.go | 2 +- internal/infra/proxy_test.go | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/internal/infra/proxy.go b/internal/infra/proxy.go index f3646334..4937fc9e 100644 --- a/internal/infra/proxy.go +++ b/internal/infra/proxy.go @@ -138,7 +138,7 @@ func proxyEnv(apiURL string) []string { "HTTP_PROXY=" + os.Getenv("HTTP_PROXY"), "HTTPS_PROXY=" + os.Getenv("HTTPS_PROXY"), "NO_PROXY=" + os.Getenv("NO_PROXY"), - "JOB_ID=" + jobID, + "JOB_ID=" + firstNonEmpty(os.Getenv("DEPENDABOT_JOB_ID"), jobID), "PROXY_CACHE=" + firstNonEmpty(os.Getenv("PROXY_CACHE"), "true"), "LOG_RESPONSE_BODY_ON_AUTH_FAILURE=true", "ACTIONS_ID_TOKEN_REQUEST_TOKEN=" + os.Getenv("ACTIONS_ID_TOKEN_REQUEST_TOKEN"), diff --git a/internal/infra/proxy_test.go b/internal/infra/proxy_test.go index 8e66ed9e..b79eb0be 100644 --- a/internal/infra/proxy_test.go +++ b/internal/infra/proxy_test.go @@ -88,6 +88,38 @@ func Test_proxyEnv_OpenSSLForceFIPSMode(t *testing.T) { }) } +func Test_proxyEnv_JobID(t *testing.T) { + for _, tt := range []struct { + name string + jobID string + unset bool + want string + }{ + {name: "uses host job ID", jobID: "1588055836", want: "1588055836"}, + {name: "defaults when empty", want: "cli"}, + {name: "defaults when unset", unset: true, want: "cli"}, + } { + t.Run(tt.name, func(t *testing.T) { + t.Setenv("DEPENDABOT_JOB_ID", tt.jobID) + if tt.unset { + if err := os.Unsetenv("DEPENDABOT_JOB_ID"); err != nil { + t.Fatal(err) + } + } + + env := proxyEnv("") + + value, ok := envValue(env, "JOB_ID") + if !ok { + t.Fatal("expected JOB_ID to be present in proxy env") + } + if value != tt.want { + t.Errorf("expected JOB_ID to be %q, got %q", tt.want, value) + } + }) + } +} + func Test_proxyEnv_JobToken(t *testing.T) { t.Run("passes JOB_TOKEN from environment", func(t *testing.T) { t.Setenv("JOB_TOKEN", "super-secret-token")