Skip to content

feat(cli): add query dry-run mode#938

Open
Arvind-puthucode wants to merge 1 commit into
HelixDB:mainfrom
Arvind-puthucode:feat/query-dry-run
Open

feat(cli): add query dry-run mode#938
Arvind-puthucode wants to merge 1 commit into
HelixDB:mainfrom
Arvind-puthucode:feat/query-dry-run

Conversation

@Arvind-puthucode

@Arvind-puthucode Arvind-puthucode commented Jun 15, 2026

Copy link
Copy Markdown

Description

Adds a --dry-run option to helix query so users can inspect the generated dynamic query request JSON without sending it to a Helix instance.

This works with all existing query inputs (--file, --json, -e/--ts, and --ts-file) and respects --compact for single-line output. Dry-run mode validates the request shape, prints the request body, and exits before loading project config or making an HTTP request.

Related Issues

N/A

Checklist when merging to main

  • No compiler warnings (if applicable)
  • Code is formatted with rustfmt
  • No useless or dead code (if applicable)
  • Code is easy to understand
  • Doc comments are used for all functions, enums, structs, and fields (where appropriate)
  • All tests pass
  • Performance has not regressed (assuming change was not to fix a bug)
  • Version number has been updated in helix-cli/Cargo.toml and helixdb/Cargo.toml (N/A - CLI behavior only)

Additional Notes

Verification run locally:

  • cargo fmt --all
  • cargo test -p helix-cli
  • HELIX_NO_UPDATE_CHECK=1 cargo run -p helix-cli --quiet -- query dev --json '{"request_type":"read","query":{"queries":[]}}' --dry-run --compact

Greptile Summary

This PR adds a --dry-run flag to helix query that validates the constructed request body and prints it (respecting --compact) without loading project configuration or making an HTTP request.

  • query.rs: dry_run: bool is added to run(); the early-return branch fires after validate_dynamic_request but before ProjectContext::find_and_load, plus a format_query_request helper and two unit tests.
  • main.rs: Adds the dry_run field to the Query enum variant, wires it into the call site, and adds a parser-level test.
  • chef.rs / README.md: Mechanical signature update and doc update respectively.

Important Files Changed

Filename Overview
helix-cli/src/commands/query.rs Adds dry_run parameter; early exit after validation but before project load; new format_query_request helper; two well-scoped unit tests.
helix-cli/src/main.rs Adds dry_run field to Query enum, example in after_help, passes flag through to query::run, adds parser-level test.
helix-cli/src/commands/chef.rs Mechanical update: adds false for the new dry_run parameter to the existing query::run call inside seed_starter_data.
helix-cli/README.md Single-line doc update noting --dry-run on the query command; accurate and consistent with the implementation.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[helix query ...args] --> B[parse_query_request\nfile / json / ts / ts_file]
    B --> C{parse OK?}
    C -- error --> Z1[return Err]
    C -- ok --> D[validate_dynamic_request\nrequest_type + warm check]
    D --> E{valid?}
    E -- error --> Z2[return Err]
    E -- ok --> F{--dry-run?}
    F -- yes --> G{verbosity\nshow_normal?}
    G -- yes --> H[format_query_request\npretty or compact]
    H --> I[println! request body]
    I --> J[return Ok]
    G -- no --> J
    F -- no --> K[ProjectContext::find_and_load\n+ dotenvy .env]
    K --> L[build reqwest request\nLocal or Enterprise]
    L --> M[POST /v1/query]
    M --> N[print response]
    N --> J
Loading

Reviews (1): Last reviewed commit: "feat(cli): add query dry-run mode" | Re-trigger Greptile

@xav-db

xav-db commented Jun 15, 2026

Copy link
Copy Markdown
Member

I like this!

@Arvind-puthucode

Copy link
Copy Markdown
Author

Hey @xav-db nice to know
i see one more reviewer to approve is required!

@xav-db

xav-db commented Jun 17, 2026

Copy link
Copy Markdown
Member

can you fix conflicts

@Arvind-puthucode

Copy link
Copy Markdown
Author

can you fix conflicts

@xav-db done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants