Skip to content

fix(ov_cli): show the underlying cause of connection errors - #6312

Merged
qin-ctx merged 1 commit into
volcengine:mainfrom
rjdotdev:fix/ov-cli-network-error-cause
Oct 20, 2026
Merged

qin-ctx merged 1 commit into
volcengine:mainfrom
rjdotdev:fix/ov-cli-network-error-cause

Conversation

@rjdotdev

@rjdotdev rjdotdev commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

ov doesn't say why a request failed. reqwest's Display only prints "error sending request for url (...)". The actual cause (TLS, DNS, connect) is in the source() chain, and Error::from_reqwest dropped it. On top of that, the Connection Error card only showed the detail in verbose mode and always guessed "offline or wrong URL", so a TLS problem looked like a dead server.

This appends the source chain in from_reqwest and shows it in the Connection Error card by default.

Human Involvement

  • A human participated in the implementation or review loop
  • This PR was generated entirely by AI agents without human participation in the loop

Related Issue

Fixes #6288

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

  • error.rs: with_sources() walks source() and appends each cause, skipping one that is already at the end of the message. All four from_reqwest branches use it, so timeout/decode/builder messages carry the cause too. The wording of those categories is unchanged.
  • error_ui.rs: the Network card puts the detail in the visible body, and the headline no longer presents offline/wrong URL as the explanation. It still points there after the detail. zh-CN copy updated to match. Other cards are untouched.
  • Tests: a unit test for the chain format and the duplicate guard, a test that hits a closed local port and checks the root cause appears exactly once, the existing network card test now checks the cause is shown, and a card test for the TLS case.

Testing

I reproduced the issue before changing anything: a self-signed HTTPS server on localhost, ov health, not verbose.

Before:

╭─ Connection Error ───────────────────────────────────────────────────╮
│ Could not reach OpenViking. The server may be offline, or this       │
│ config points to the wrong URL.                                      │
╰──────────────────────────────────────────────────────────────────────╯

After:

╭─ Connection Error ───────────────────────────────────────────────────╮
│ Could not reach OpenViking. Check the detail first, then whether the │
│ server is running and the URL is correct. Detail: HTTP request       │
│ failed: error sending request for url                                │
│ (https://127.0.0.1:35511/health): client error (Connect): invalid    │
│ peer certificate: UnknownIssuer                                      │
╰──────────────────────────────────────────────────────────────────────╯

ov -o json health before:

{"ok":false,"error":{"code":"UNAVAILABLE","message":"Network error: HTTP request failed: error sending request for url (https://127.0.0.1:34747/health)"}}

After:

{"ok":false,"error":{"code":"UNAVAILABLE","message":"Network error: HTTP request failed: error sending request for url (https://127.0.0.1:35511/health): client error (Connect): invalid peer certificate: UnknownIssuer"}}

With nothing listening, the card now ends in tcp connect error: Connection refused (os error 111).

Commands run locally:

  • RUST_MIN_STACK=67108864 cargo test -p ov_cli: 509 unit + 4 integration tests pass. The larger stack is needed because some help_ui tests overflow the default stack on main as well. I ran it with a throwaway HOME that only has the CLI language set, since two config integration tests wait for a language prompt otherwise.
  • cargo clippy -p ov_cli --all-targets: no warnings in the touched files
  • rustfmt --check --edition 2024 crates/ov_cli/src/error.rs crates/ov_cli/src/error_ui.rs: clean
  • git diff --check: clean

As far as I can see, CI doesn't run cargo test for ov_cli, so the above is the test signal for this change.

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Additional Notes

  • Out of scope, as in the issue: trusting a private CA ([Feature]: ov CLI cannot trust a private CA certificate #6289), and rewording the timeout/decode/builder categories.
  • The card still starts with "Could not reach OpenViking" and keeps the "Connection Error" title, so the retry markers in tests/cli/conftest.py still match.
  • The cause is in the same paragraph as the headline because wrap_text collapses newlines. I didn't want to change card rendering for every error type in this PR.
  • I used AI tools while working on this. I reviewed the change, can explain every line, and ran the tests above myself.

reqwest's Display drops the source() chain.
from_reqwest now appends it so JSON and table output name causes like
invalid peer certificate: UnknownIssuer. The Connection Error card shows
the cause by default instead of only guessing offline or wrong URL.

Fixes volcengine#6288
Copilot AI balanced review requested due to automatic review settings October 19, 2026 19:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@qin-ctx
qin-ctx merged commit a9cb3b4 into volcengine:main Oct 20, 2026
@github-project-automation github-project-automation Bot moved this from Backlog to Done in OpenViking project Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: ov connection errors hide the underlying cause

3 participants