hyperledger / hyperledger/fabric-x
samples/tokens/issuer: Silent error discard in os.Getwd() leads to unpredictable behavior
- Dominant language
- Go
- Stars
- 64
- Forks
- 80
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 15
Description
Summary
In samples/tokens/issuer/main.go, the error returned by os.Getwd() is silently discarded using _. If the call
fails, cwd will be an empty string and the program will continue with an invalid working directory path, causing
confusing downstream failures with no indication of the root cause.
Location
samples/tokens/issuer/main.go, line 32
Current Code
cwd, _ := os.Getwd()
Problem
- os.Getwd() can fail if the working directory has been deleted, a parent directory has had its permissions
revoked, or a mounted filesystem has been unmounted.
- When it fails, cwd becomes "" (empty string).
- This empty string is passed directly to common.StartFSC(*pth, path.Join(*pth, "data")), causing the FSC node to
start with a wrong/missing config path.
- The program fails later with a misleading error, not at the point where it could have exited cleanly.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.