Skip to content
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

Remove circular dependency when logging configuration loading error #693

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

notarock
Copy link
Contributor

Closes #689

When the configuration fails to load properly, an error gets logged using Log(). This logger requires the configuration to be loaded properly to function. Calling Log().fatal when a configuration loading error occurs causes a panic which obstructs the configuration error and confuses users.

By downgrading to use the built in log package when handling this error, we can get some pretty valuable info on why the configuration has failed to load.

Before:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x8 pc=0x104b276a0]

goroutine 1 [running]:
github.com/muety/wakapi/config.(*Config).IsDev(...)
	/Users/notarock/src/wakapi/config/config.go:228
github.com/muety/wakapi/config.Log()
	/Users/notarock/src/wakapi/config/sentry.go:31 +0x30
github.com/muety/wakapi/config.Load({0x104d40ea7, 0xa}, {0x104d39d00, 0x4})
	/Users/notarock/src/wakapi/config/config.go:474 +0xbc
main.main()
	/Users/notarock/src/wakapi/main.go:122 +0x12c
exit status 2

After

2024/10/15 01:23:11 failed to read configyaml: unmarshal errors:
  line 14: cannot unmarshal !!str `tcp:80` into int
exit status 1

@muety muety merged commit 24044aa into muety:master Oct 15, 2024
6 of 7 checks passed
muety added a commit that referenced this pull request Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configuration loading errors are not logged properly due to a dependency on Config being loaded
2 participants