fix: env var decoding for bool config fields, redis sentinel multi-node support and change fs.FS path construction#4545
fix: env var decoding for bool config fields, redis sentinel multi-node support and change fs.FS path construction#4545vsengar-79 wants to merge 6 commits into
Conversation
Signed-off-by: vsengar-79 <146079793+vsengar-79@users.noreply.github.com>
Signed-off-by: vsengar-79 <146079793+vsengar-79@users.noreply.github.com>
Signed-off-by: vsengar-79 <146079793+vsengar-79@users.noreply.github.com>
Signed-off-by: vsengar-79 <146079793+vsengar-79@users.noreply.github.com>
filepath.Join uses the OS path separator (\ on Windows), which breaks fs.FS implementations that require forward-slash paths per the io/fs spec. Replace with path.Join which always uses /. Signed-off-by: vsengar-79 <146079793+vsengar-79@users.noreply.github.com>
📝 WalkthroughWalkthroughFour small independent fixes: a casing typo in the sink Kafka consumer group viper key, a new ChangesMisc Fixes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/redis/client.go`:
- Around line 61-68: The code splits and trims sentinel addresses but does not
filter out empty strings that can result from trailing, leading, or double
commas in the address string. After trimming each address in the sentinelAddrs
loop, filter out any entries that are empty strings. Additionally, add
validation after the loop to ensure the final sentinelAddrs slice is not empty,
and fail fast with an appropriate error message if no valid sentinel addresses
remain after filtering.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 28f3a5df-20d6-455d-bc7f-ff317c165a1e
📒 Files selected for processing (4)
app/config/sink.goapp/config/viper.gopkg/redis/client.gotools/migrate/fs.go
Greptile SummaryFour small but meaningful bug-fixes for Kubernetes deployments where config arrives as env var strings. Covers bool coercion during viper decode, a Kafka consumer group ID key typo, Redis Sentinel multi-node address support, and cross-platform
Confidence Score: 5/5All four changes are targeted, backward-compatible bug fixes with no new logic paths that could regress existing behaviour. Each change is narrowly scoped: a one-line hook addition, a key-name typo fix, an address-parsing loop with an explicit guard, and an import swap. No new abstractions, no schema changes, and the sentinel parsing is explicitly backward-compatible with single-address strings. No files require special attention. Important Files Changed
|
Refactor sentinel address handling to trim whitespace and validate addresses. Signed-off-by: vsengar-79 <146079793+vsengar-79@users.noreply.github.com>
Overview
Four small fixes for running OpenMeter in Kubernetes where config values arrive as environment variable strings rather than typed YAML values.
app/config/viper.go— bool env var decodingAdded
StringToBasicTypeHookFunc()to the globalDecodeHook. When config values are set via env vars or ConfigMaps, they are always strings —"true","false","1". Without this hook, anyboolconfig field panics on startup with:This affects fields like
DEDUPE_ENABLED,NOTIFICATION_ENABLED, and any other boolean config sourced from the environment.app/config/sink.go— consumer group ID key name typosink.kafka.consumerGroupId→sink.kafka.consumerGroupID(capitalIDto match the struct field's mapstructure tag). Fixed a little typo.pkg/redis/client.go— Redis Sentinel multi-node supportThe
Addressfield now supports a comma-separated list of sentinel nodes (e.g."sentinel1:26379,sentinel2:26379,sentinel3:26379"). Previously it was hardcoded to[]string{o.Address}, which only ever used a single sentinel endpoint regardless of what was configured.tools/migrate/fs.go— usepath.Joininstead offilepath.Joinforfs.FSpath constructionfilepath.Joinuses the OS path separator (\on Windows), which breaksfs.FSimplementations that require forward-slash paths per theio/fsspec. Replace withpath.Joinwhich always uses/Notes for reviewer
StringToBasicTypeHookFunconly activates when the target struct field is a basic type (bool,int,float64) — it has no effect on string fields orinterface{}maps. Existing YAML-based configs are unaffected since YAML already deserialises native types correctly.strings.Spliton a non-comma string returns a single-element slice, identical to the previous[]string{o.Address}behaviour.pathpackage (always forward-slash) is used instead offilepath(OS-dependent separator) becausefs.FSrequires forward-slash paths on all platforms per theio/fsspec; the function parameter was renamed frompathtodirto avoid shadowing the import.Summary by CodeRabbit
Summary by CodeRabbit
New Features
Improvements
Bug Fixes