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

Runtime error #82

Closed
Ederene20 opened this issue Jul 13, 2024 · 5 comments
Closed

Runtime error #82

Ederene20 opened this issue Jul 13, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@Ederene20
Copy link
Collaborator

Describe the bug
Getting a runtime error when running go run main.go .

To Reproduce
Steps to reproduce the behavior:

  1. Go to sendhooks directory
  2. Execute go run main.go
  3. See error

Expected behavior

I get the following error in the terminal :

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x67cc0c]

goroutine 1 [running]:
main.main()
	/sendhooks-engine/sendhooks/main.go:36 +0x2cc
exit status 2

Screenshots

Screenshot from 2024-07-13 07 54 43

Desktop:

  • OS: Ubuntu (Elementary OS 7.1 Horus)
  • Version: 22
@Ederene20 Ederene20 added the bug Something isn't working label Jul 13, 2024
@cedrick-ah
Copy link
Contributor

I think that it is because the configuration are direclty parsed from the config.json file without any adaptation to match the configuration structure in code. This led to undefined variables in the configuration and therefore we have pointers that point to nothing. When trying to manipulate these null pointers we then get the so-called error. I will submit a PR to fix it.
The error is here:

func LoadConfiguration(filename string) {
	once.Do(func() {
		file, err := os.Open(filename)
		if err != nil {
			log.Fatalf("Failed to open config file: %v", err)
		}
		defer file.Close()

		decoder := json.NewDecoder(file)
		err = decoder.Decode(&config) // config structure do not match config.json file structure
		fmt.Printf("&s", config.Broker)
		if err != nil {
			log.Fatalf("Failed to decode config file: %v", err)
		}
	})
}

@koladev32
Copy link
Collaborator

@cedrick-ah thanks for the diagnosis. I will check the PRs in few hours

@cedrick-ah
Copy link
Contributor

Okay, I will be waiting for it.

@koladev32
Copy link
Collaborator

@Ederene20 please pull the project on the main branch to confirm the issue has been resolved.

@Ederene20
Copy link
Collaborator Author

@Ederene20 please pull the project on the main branch to confirm the issue has been resolved.

@koladev32 The issue has been resolved. Thank you @cedrick-ah !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants