Skip to content

fix: normalize --storage flag to absolute path in preRun #29

@coderabbitai

Description

@coderabbitai

Summary

The storageDir value read from the --storage flag in the preRun method of workspace commands (e.g. pkg/cmd/workspace_list.go) is passed directly to instances.NewManager() without being converted to an absolute path first.

Per coding guidelines, relative paths must be normalized using filepath.Abs() in the preRun method to ensure deterministic behavior regardless of the caller's working directory.

Steps to reproduce

Run kortex workspace list --storage ./relative/path from different working directories and observe inconsistent behavior.

Suggested fix

Add a filepath.Abs() call after reading the --storage flag and before passing it to instances.NewManager():

storageDir, err = filepath.Abs(storageDir)
if err != nil {
    return fmt.Errorf("failed to resolve --storage path: %w", err)
}

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions