From 376d25a97f3a1640ff8cbbddaa4af25948df2cf3 Mon Sep 17 00:00:00 2001 From: Nikolai Emil Damm Date: Sat, 11 Apr 2026 11:59:22 +0200 Subject: [PATCH] fix: detect ubuntu-slim runners early and bail out ubuntu-slim runners (Hosted Compute Agent Docker containers) are GitHub-hosted but lack the standard USER environment variable set on full VM-based runners. This causes chownForFolder to fail with 'chown: invalid user: undefined'. Instead of patching chownForFolder, detect ubuntu-slim early informative message, matching the existing patterns for isDocker(), isARCRunner(), and other unsupported runner types. Fixes #627 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/cleanup.ts | 5 +++++ src/common.ts | 3 +++ src/setup.ts | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/src/cleanup.ts b/src/cleanup.ts index 5a1c450..8d8e531 100644 --- a/src/cleanup.ts +++ b/src/cleanup.ts @@ -26,6 +26,11 @@ import { isPlatformSupported, isAgentInstalled } from "./utils"; return; } + if (isGithubHosted() && process.platform === "linux" && !process.env.USER) { + console.log(common.UBUNTU_SLIM_MESSAGE); + return; + } + if (isARCRunner()) { console.log(`[!] ${common.ARC_RUNNER_MESSAGE}`); return; diff --git a/src/common.ts b/src/common.ts index 81f36bf..0409778 100644 --- a/src/common.ts +++ b/src/common.ts @@ -148,3 +148,6 @@ export const ARM64_RUNNER_MESSAGE = export const ARM64_WINDOWS_RUNNER_MESSAGE = "Windows ARM runners are not yet supported by Harden-Runner."; + +export const UBUNTU_SLIM_MESSAGE = + "This job is running on an ubuntu-slim runner (GitHub-hosted Linux container without a standard USER environment variable). Harden Runner is not supported on ubuntu-slim runners. This job will not be monitored."; diff --git a/src/setup.ts b/src/setup.ts index bd45f33..b22fc75 100644 --- a/src/setup.ts +++ b/src/setup.ts @@ -64,6 +64,11 @@ interface MonitorResponse { return; } + if (isGithubHosted() && process.platform === "linux" && !process.env.USER) { + console.log(common.UBUNTU_SLIM_MESSAGE); + return; + } + var correlation_id = uuidv4(); var api_url = STEPSECURITY_API_URL; var web_url = STEPSECURITY_WEB_URL;