Skip to content

fix(dataset push): expand ~ in the dataset path (interactive prompt resolves ~/… under CWD) #37

@aptracebloc

Description

@aptracebloc

Summary

dataset push doesn't expand a leading ~ in the dataset path, so a ~/… path resolves relative to the current directory instead of $HOME. Found while prepping a live demo of the interactive flow (#28).

Impact

Bites the interactive prompt in particular: a user types ~/tb-fixtures/tab-reg at the "Path to your dataset directory" prompt and gets:

Error: reading dataset directory "/Users/arturo/work/cli/~/tb-fixtures/tab-reg":
stat /Users/arturo/work/cli/~/tb-fixtures/tab-reg: no such file or directory

(Also affects a quoted/literal ~ passed as the positional arg, e.g. in a --no-input script.)

Why it happens

~ is expanded by the shell, not the program:

  • On the command line, tracebloc dataset push ~/x → the shell rewrites ~$HOME before the CLI runs, so the flag form works.
  • From the survey prompt the shell isn't involved — the CLI receives the literal ~/x, and push.Discover / push.DiscoverTabular call filepath.Abs(rootDir), which doesn't expand ~; it just prepends the CWD.

The fix already exists in spirit: cluster.expandPath (internal/cluster/kubeconfig.go) does ~$HOME for --kubeconfig; the dataset path goes through nothing equivalent.

Proposed fix

  • Expand ~ / ~/…$HOME for the dataset path, mirroring cluster.expandPath.
  • Apply it in the CLI layer (runDatasetPush, where a.LocalPath is resolved) so it covers both the interactive prompt and a quoted ~ arg in one place — before any Discover* call.
  • (Bonus) give the interactive path prompt a survey validator that checks the directory exists and re-prompts, so a typo is caught in-flow instead of after.

Acceptance criteria

  • ~/x and ~ resolve under $HOME; relative (./x) and absolute paths unchanged.
  • Works for both the interactive prompt and a literal ~ positional arg.
  • Unit test covering ~/x$HOME/x, ./x, and absolute passthrough.
  • (Optional) interactive path prompt validates the dir exists + re-prompts.
  • make ci green.

Workaround (in place)

Use an absolute path in the interactive prompt; the demo run-sheet was updated accordingly. The command-line flag form already tolerates ~ (shell-expanded).

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

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