Skip to content

fix(cli): guide localhost transport failures to gateway start#88

Merged
lentil32 merged 3 commits intomainfrom
fix/cli-local-gateway-guidance
Apr 14, 2026
Merged

fix(cli): guide localhost transport failures to gateway start#88
lentil32 merged 3 commits intomainfrom
fix/cli-local-gateway-guidance

Conversation

@lentil32
Copy link
Copy Markdown
Contributor

One-Line Summary

Make localhost self-host transport failures tell users to start the managed gateway instead of surfacing a generic Connect error.

User-Facing Changes

  • When the CLI server points at a managed local self-host origin such as http://127.0.0.1:5656 and nothing is listening, commands now fail with self-host gateway is not running and actionable next steps like onequery gateway start.
  • The localhost gateway guidance now applies consistently across auth, org, source, query, source connect, and api command surfaces, not just onequery auth login.
  • The rendered error now names the configured origin, the probed host and port, and a retry <command> follow-up instead of only showing a raw transport failure.

Why This Changed

  • The CLI previously treated a stopped localhost self-host gateway like any other transport outage and surfaced generic Connect/HTTP client errors such as client error (Connect).
  • That lost the key operational context: for the managed self-host flow, the right next action is usually to start the gateway, not to debug an arbitrary network path.
  • The original matching path also required both config.toml and secrets.toml, which could miss custom local self-host routing data during partial setup.

How It Changed

  • Added crates/onequery-cli/src/local_target.rs to classify managed local self-host targets, normalize loopback probe hosts, and construct a dedicated self_host_gateway_unavailable CLI error.
  • Routed API transport failures through present_api_failure_with_context(...) so commands can upgrade matched local self-host outages before falling back to the generic transport presenter.
  • Reused the same runtime connection probe helpers from the gateway runtime path instead of keeping separate localhost probing logic.
  • Extracted self_host_public_origin(...) and added a public-config-only loader so target resolution can use config.toml routing fields without depending on secrets.toml.
  • Added snapshot and unit coverage for the new user-visible error rendering and for custom public-config loading/matching.

Bug Fixes

  • Under the default self-host setup, onequery auth login could fail with login start failed and a raw Connect transport error when the gateway was simply stopped; it now points users to onequery gateway start.
  • When a custom local self-host config.toml existed without secrets.toml, local target detection could miss the configured local endpoint; it now reads the public config independently.

Extra Context / Decisions (Optional)

  • This intentionally treats matched managed localhost self-host targets as a first-class operational state instead of a generic transport failure. Remote origins still fall back to the existing API failure presentation.

Verification

  • cargo test -p onequery-cli
  • just fix -p onequery-cli
  • just fmt
  • bun run format
  • Added snapshot coverage in apps/cli/crates/onequery-cli/src/snapshots/onequery__local_target__tests__managed_gateway_unavailable_error_snapshot_guides_gateway_start_for_local_targets.snap.
  • Added unit coverage in apps/cli/crates/onequery-cli/src/local_target.rs for default localhost matching, custom local runtime matching, and remote-origin opt-out.
  • Added unit coverage in apps/cli/crates/onequery-cli/src/config/self_host.rs for loading public self-host config without secrets.toml.

Video / Screenshot (Optional)

  • N/A

@lentil32 lentil32 requested a review from siisee11 as a code owner April 14, 2026 12:06
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 14, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
onequery-landing 9dc3f5a Commit Preview URL

Branch Preview URL
Apr 14 2026, 12:53 PM

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c9aa49a983

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/cli/crates/onequery-cli/src/local_target.rs Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dbaf955e31

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/cli/crates/onequery-cli/src/local_target.rs
@lentil32 lentil32 merged commit 8ea2271 into main Apr 14, 2026
7 checks passed
@lentil32 lentil32 deleted the fix/cli-local-gateway-guidance branch April 14, 2026 12:54
lentil32 added a commit that referenced this pull request Apr 15, 2026
You can install any of these versions: `npm install -g @onequery/cli@<version>`
## [0.1.29] - 2026-04-15
### 🚀 Features

- Update landing page copy and sample visuals (#86)
- Landing diagram redesign (#91)
- *(repo)* Add OpenClaw plugin for OneQuery (#90)

### 🪲 Bug Fixes

- *(cli-release)* Use versioned homebrew asset names (#87)
- *(cli)* Guide localhost transport failures to gateway start (#88)

### 💼 Other

- *(cli)* Align config set/get around canonical keys (#89)
<!-- generated - do not edit -->
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.

1 participant