Skip to content

CLI context resolution is inconsistent across command-line inputs, env vars, and local config #6

Description

@ndeybach

The CLI should resolve context from one source:

  • Command-line inputs
  • XATA_* env vars
  • Initialized local config

Or possibly multiple, but with clear precedence and required or not scope !

Current behavior is inconsistent: some env vars work, some are detected but not used, and clone commands still require local init even when command-line inputs are complete. (and possibly other commands are also problematic, I did not dig into all of them (yet) ).

Confirmed failures:

  1. Env vars partly work, but XATA_PROJECT_ID is not used where projectID is required. (and possibly other cases of wrong behavior / discovery on other env vars, did not note down all of the cases).

Works:

XATA_ORGANIZATION_ID="$ORGID" xata-cli project list --json

Fails:

XATA_ORGANIZATION_ID="$ORGID" \
XATA_PROJECT_ID="$PROJECTID" \
xata-cli branch list --json

Actual, with the command name substituted:

Error: Missing required path parameter: projectID

Same projectID failure with:

  • xata-cli branch metrics --json
  • xata-cli clone start ...
  • xata-cli clone stream ...

This still fails after also setting XATA_BRANCH_ID, XATA_BRANCH, and XATA_DATABASE. The CLI prints those env-derived values in its config status, but does not use project_id for the API path.

  1. Clone commands still require xata init even when command-line inputs are complete.
xata-cli clone <start|stream> \
  --source-url "$SCALEWAY_DB2_URL" \
  --target postgres \
  --organization "ORGID" \
  --project "PROJECTID" \
  --branch "BRANCHID" \
  --target-url "$XATA_DB1_URL" \
  --validation-mode relaxed

Actual:

Error: xata clone <start|stream> command only works when using a config file based project.
Please use xata init command to initialize a new project.

Minimum-context rule:

Only require values used by the command.

xata-cli project list --organization "$ORGID"
xata-cli branch list --organization "$ORGID" --project "$PROJECTID"
xata-cli clone start --organization "$ORGID" --project "$PROJECTID" --branch "$BRANCHID" ...

Expected behavior:

  • Precedence: command-line inputs > env vars > local config.
  • Do not require duplicate context from another source.
  • Do not require unrelated context for the current command.
  • If something is missing, report the specific missing value.

Version: confirmed with xata-cli 1.5.4

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