cortex
cortex copied to clipboard
Fix panic on startup if the ExternalURL field in the ruler config is empty
If ExternalURL is ""
in the ruler config, it will be unmarshaled into a nil *URL
object, causing a nil pointer dereference when building the ruler config. The String()
helper (which performs the correct nil-check) on the ExternalURL
's wrapper type was likely intended to be used to obtain the url string, but the nested *URL
struct's String()
was called instead, causing a panic if it's nil.
What this PR does:
Which issue(s) this PR fixes:
Fixes #
Checklist
- [ ] Tests updated
- [ ] Documentation added
- [ ]
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]
Nice catch.
Can you add a test for it? with a valid url as well?
Sure thing :+1:
I'm not sure exactly where a test for this would go - since there wasn't anything wrong with the URL wrapper code itself, just the usage, maybe it could be added in an integration test somewhere? Could you point me in the right direction?
We can try to create a a config with a problematic entry and run the test (make sure we dont throw an error).
A simple test is enough, just create the bad config and call DefaultTenantManagerFactory