mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 13:11:49 +00:00
chore(config): clarify env var already registered panic (#63784)
When `internal/env/env.Get` detects a difference in between already registered descriptions, it panics (good). But the error message doesn't tell you what's the difference and you're left out to put a few prints for yourself in the code to try to understand what's wrong. See also: https://github.com/sourcegraph/sourcegraph/pull/63786 Before: <img width="1109" alt="image" src="https://github.com/sourcegraph/sourcegraph/assets/10151/56b2d65c-ef87-4134-bfc0-67248aa48350"> After:  ## Test plan CI + local run ## Changelog - When conflicting env var are detected, print the two to ease debugging.
This commit is contained in:
parent
46794b5677
commit
ec34a909bc
2
internal/env/env.go
vendored
2
internal/env/env.go
vendored
@ -97,7 +97,7 @@ func Get(name, defaultValue, description string) string {
|
||||
|
||||
e := envflag{description: description, value: value}
|
||||
if existing, ok := env[name]; ok && existing != e {
|
||||
panic(fmt.Sprintf("env var %q already registered with a different description or value", name))
|
||||
panic(fmt.Sprintf("env var %q already registered with a different description or value\n\tBefore: %q\n\tAfter: %q", name, existing, e))
|
||||
}
|
||||
env[name] = e
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user