Skip to content

Conversation

pinotelio
Copy link

Fix environment variable mapping for read-only mode configuration

Add SetEnvKeyReplacer to viper configuration to properly map environment variables with underscores to flag names with dashes. This enables the documented GITHUB_READ_ONLY=1 environment variable to work correctly.

Without this fix, viper was looking for GITHUB_READ-ONLY (with dash) but the documentation and standard convention use GITHUB_READ_ONLY (with underscore).

Fixes issue where read-only mode was not being activated when using GITHUB_READ_ONLY=1 in Docker containers.

Incorrect Read-Only Tools when GITHUB_READ_ONLY=1 passed:
Incorrect Read-Only Tools

Test with GITHUB_READ-ONLY=1 (Dash):
Test With Dash

Correct Result After The Patch:
Patched

Requirement Command Status
✅ Tests pass go test -v ./... PASSED
✅ Linter passes golangci-lint run PASSED
✅ Project linter script/lint PASSED
✅ Update snapshots UPDATE_TOOLSNAPS=true go test ./... COMPLETED
✅ Update docs script/generate-docs COMPLETED

Closes:

Fix environment variable mapping for read-only mode configuration

Add SetEnvKeyReplacer to viper configuration to properly map environment
variables with underscores to flag names with dashes. This enables the
documented GITHUB_READ_ONLY=1 environment variable to work correctly.

Without this fix, viper was looking for GITHUB_READ-ONLY (with dash) but
the documentation and standard convention use GITHUB_READ_ONLY (with
underscore).

Fixes issue where read-only mode was not being activated when using
GITHUB_READ_ONLY=1 in Docker containers.
@pinotelio pinotelio requested a review from a team as a code owner September 9, 2025 00:09
@pinotelio
Copy link
Author

ping @tonytrg :)

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