Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

fix address panic when $HOME environment is not defined#41

Open
r-mol wants to merge 2 commits intotemporalio:mainfrom
r-mol:main
Open

fix address panic when $HOME environment is not defined#41
r-mol wants to merge 2 commits intotemporalio:mainfrom
r-mol:main

Conversation

@r-mol
Copy link

@r-mol r-mol commented Apr 25, 2023

What was changed

pkg/config/config.go ->
os.UserHomeDir() returns an error only when $HOME environment is not set. Therefore, instead of returning an error, the dir variable is set to a temporary directory (using the os.TempDir() function), this helps to avoid address panic in the future.

pkg/config/config_test.go ->

  1. Added a test to check when environment $HOME is not set.
  2. Сhanged the test because it didn't pass if the .config directory wasn't created before the test was run.

Why?

I was getting address panic after trying to create a new TCTL config. This was happening because environment $HOME was not set.

Checklist

  1. How was this tested:
  • By internal tests, but with unset $HOME environment
  • By running temporalio/tctl with modified temporalio/tctl-kit
  1. Any docs updates needed? NO

r-mol added 2 commits April 25, 2023 16:57
Сhanged the test because it didn't pass if the .config directory wasn't created before the test was run.
1. os.UserHomeDir() returns an error only when $HOME environment is not set. Therefore, instead of returning an error, the dir variable is set to a temporary directory (using the os.TempDir() function), this helps to avoid address panic in the future.

2. Added a test to check when environment $HOME is not set.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant