-
Notifications
You must be signed in to change notification settings - Fork 3.7k
fix: dont panic when schema_config does not exist in the config file #16702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused how is Loki going to work without a schema config? Would you mind sharing the config you're running and how you are storing the data?
The thing I wanted to change it to know why the config is wrong. With this change, the binary outputs this, which helps me debut faster
|
I see what the problem is: There's is a panic in the config validation, because it accesses properties of the schema_config even if it is not present. This is definitely a bug and not expected behaviour. @trevorwhitney Loki still will not start up without a schema_config, because the validation would fail. However it would terminate gracefully. |
if len(c.SchemaConfig.Configs) == 0 { | ||
return []error{} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add a comment mentioning that the length of c.SchemaConfig.Configs is already validated in the Validate()
function of the SchemaConfig itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I added the comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand now, lgtm
Apparently I need to lint this code before the lint check can pass. I tried running |
What this PR does / why we need it:
initial startup should not panic
Which issue(s) this PR fixes:
Fixes #16698
Special notes for your reviewer:
Checklist
CONTRIBUTING.md
guide (required)feat
PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.docs/sources/setup/upgrade/_index.md
deprecated-config.yaml
anddeleted-config.yaml
files respectively in thetools/deprecated-config-checker
directory. Example PR