Skip to content

samples/tokens/issuer: Silent error discard in os.Getwd() leads to unpredictable behavior #243

@karthik120710

Description

@karthik120710

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions