Skip to content

Expose project scope in managed local client errors - #518

Open
sdairs wants to merge 2 commits into
issue-477-server-project-scope-errorsfrom
issue-467-client-project-scope-errors
Open

Expose project scope in managed local client errors#518
sdairs wants to merge 2 commits into
issue-477-server-project-scope-errorsfrom
issue-467-client-project-scope-errors

Conversation

@sdairs

@sdairs sdairs commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • identify managed local client mode and the canonical current project directory for missing, stopped, and missing-binary failures
  • preserve inherited structured error codes while adding safe mode and project fields, concise human guidance, and fixed recovery commands
  • cover exact-directory lookup, including empty projects, child directories, explicit names, stopped metadata, and telemetry redaction

Closes #467

Tests

  • cargo fmt --all --check
  • cargo build -p clickhousectl
  • cargo check -p clickhousectl --no-default-features
  • cargo test -p clickhousectl (636 unit tests plus all integration suites)
  • cargo clippy -p clickhousectl --all-targets -- -D warnings
  • cargo clippy -p clickhousectl --no-default-features --all-targets -- -D warnings

Stack

let project = canonical_project_dir()?;
server::recover_current_project_servers()
.map_err(|error| error.with_managed_client_scope(project.clone()))?;
let lock = server::ServerLock::acquire(server_name)?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium local/mod.rs:280

When ServerLock::acquire(server_name) cannot create or open the lock, run_client returns the raw metadata error, so managed-client JSON omits mode and project and human output omits the project-scope recovery guidance. Map this error through with_managed_client_scope(project.clone()) like load_info and is_running.

Suggested change
let lock = server::ServerLock::acquire(server_name)?;
let lock = server::ServerLock::acquire(server_name)
.map_err(|error| error.with_managed_client_scope(project.clone()))?;
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @crates/clickhousectl/src/local/mod.rs around line 280:

When `ServerLock::acquire(server_name)` cannot create or open the lock, `run_client` returns the raw metadata error, so managed-client JSON omits `mode` and `project` and human output omits the project-scope recovery guidance. Map this error through `with_managed_client_scope(project.clone())` like `load_info` and `is_running`.

@sdairs
sdairs changed the base branch from issue-472-atomic-server-metadata to issue-477-server-project-scope-errors August 24, 2026 21:37
@sdairs sdairs changed the title issue 467 client project scope errors Expose project scope in managed local client errors Aug 24, 2026

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1eb8e3e. Configure here.

.map_err(|error| error.with_managed_client_scope(project.clone()))?;
let lock = server::ServerLock::acquire(server_name)?;
let info = lock
.load_info()?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Managed scope skips lock acquire

Medium Severity

ServerLock::acquire in managed local client is not passed through with_managed_client_scope, unlike recover, load_info, ServerNotFound, is_running, and ServerNotRunning. Lock and permission failures that already produce whitelisted ServerMetadata* errors therefore omit mode, project, and the managed recovery text, even though those variants have dedicated recovery copy in with_managed_client_scope.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1eb8e3e. Configure here.

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.

Make local client managed-state errors explain project scope

1 participant