bazelbuild / bazelbuild/bazelisk

Refactor: normalize config values at the config layer

Open
#767 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.7k
Forks
424
PR merge metrics
No merged PRs in 30d

Description

## Summary

Currently, config value normalization (e.g., `strings.ToLower` for SHA256 hashes) happens at each call site when retrieving values. This leads to repetitive normalization calls scattered throughout the codebase.

## Current Pattern

```go
// In getExpectedSHA256
if hash := cfg.Get("BAZELISK_VERIFY_SHA256_" + suffix); hash != "" {
return strings.ToLower(hash)
}
```

Similar patterns exist in other places like `getBazeliskHome` with `strings.ToUpper`.

## Proposed Improvement

Normalize values once at the config layer (when storing/loading), so all consumers can assume values are already in the expected format.

This would:
- Reduce code duplication
- Prevent bugs from forgotten normalization
- Make the codebase cleaner

## Related

This was identified while working on #766 (platform-specific SHA256 verification).

Contributor guide

Open the contributing guide

Research direction

Start by tracing the config storage/loading layer and the call sites named in the issue, especially getExpectedSHA256 and getBazeliskHome. The work is done when normalization is handled centrally and those consumers no longer repeat it, while existing behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.