Skip to content

fix(config): load runner registration token from file on server#3872

Draft
cursor[bot] wants to merge 1 commit into
developfrom
cursor/critical-correctness-bugs-6826
Draft

fix(config): load runner registration token from file on server#3872
cursor[bot] wants to merge 1 commit into
developfrom
cursor/critical-correctness-bugs-6826

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented May 20, 2026

Bug and impact

If the Semaphore process was configured with only a runner registration token file (registration_token_file / SEMAPHORE_RUNNER_REGISTRATION_TOKEN_FILE), the token was never applied to RunnerRegistrationToken. The runner registration HTTP handler treats an empty RunnerRegistrationToken as invalid, so every registration attempt failed even when the client sent the correct token read from its own copy of the file. This primarily affects deployments that mount Docker/Kubernetes secrets via a *_FILE environment variable.

Root cause

initRunnerRegistrationToken() (which reads the file into Runner.RegistrationToken) runs only in the runner CLI (runner start / register), not during general ConfigInit used by the server. The API compares the request body to Config.RunnerRegistrationToken, which stayed empty when only the file path was configured.

Fix

During ConfigInit, after loading environment and defaults, read Runner.RegistrationTokenFile when set and populate RunnerRegistrationToken and Runner.RegistrationToken only when those strings are still empty (so an inline env token continues to take precedence).

Validation

  • go test ./util -count=1 (includes new tests for file-only and env-precedence cases).
Open in Web View Automation 

When only registration_token_file (or SEMAPHORE_RUNNER_REGISTRATION_TOKEN_FILE)
was set, RunnerRegistrationToken stayed empty so the runner registration API
rejected every request. Read the file during ConfigInit and fill the inline
token fields when they are still empty so file-based secrets match the runner
client and API validation.

Co-authored-by: Denis Gukov <fiftin@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant