Skip to content

fix(alias): validate endpoint URLs before saving#183

Merged
overtrue merged 2 commits intomainfrom
codex/fix-181-alias-endpoint
May 7, 2026
Merged

fix(alias): validate endpoint URLs before saving#183
overtrue merged 2 commits intomainfrom
codex/fix-181-alias-endpoint

Conversation

@overtrue
Copy link
Copy Markdown
Contributor

@overtrue overtrue commented May 7, 2026

Related Issue

Closes #181

Background

Issue #181 reports configuring an alias with http://rustfs-node{1...32}:9000, then seeing rc ls rustfs fail with Network error: dispatch failure.

That endpoint is RustFS server volume expansion syntax, not a single S3 service endpoint. rc alias set only rejected empty endpoints, so the invalid endpoint could be saved and fail later during the S3 request.

Solution

  • Add shared alias endpoint validation in rc-core.
  • Require HTTP(S) URLs with a host.
  • Reject RustFS volume expansion patterns before saving aliases.
  • Return a usage error from rc alias set when the endpoint is invalid.

Tests

  • cargo test -p rc-core validate_alias_endpoint --lib
  • cargo test -p rustfs-cli commands::alias::tests --lib
  • RC_CONFIG_DIR=<tmp> cargo run -q -p rustfs-cli -- alias set rustfs 'http://rustfs-node{1...32}:9000' xxx xxx returns exit code 2
  • make pre-commit

Copilot AI review requested due to automatic review settings May 7, 2026 08:13
@overtrue overtrue added bug Something isn't working codex codex-automation labels May 7, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces shared validation for alias endpoints so rc alias set rejects invalid S3 service URLs (notably RustFS volume expansion patterns) before persisting them, preventing later runtime/network failures.

Changes:

  • Added validate_alias_endpoint to rc-core and re-exported it publicly.
  • Reused shared HTTP(S)+host validation for env-based aliases and CLI input.
  • Added unit tests in rc-core and CLI tests ensuring invalid endpoints are rejected with a usage error.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
crates/core/src/lib.rs Re-exports the new shared endpoint validation API from rc-core.
crates/core/src/alias.rs Adds validate_alias_endpoint, factors out HTTP(S)+host validation, and adds tests.
crates/cli/src/commands/alias.rs Validates endpoints in alias set before saving; adds CLI test for invalid endpoint rejection.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/core/src/alias.rs
Comment thread crates/cli/src/commands/alias.rs
@overtrue overtrue merged commit 9a0f5f9 into main May 7, 2026
15 checks passed
@overtrue overtrue deleted the codex/fix-181-alias-endpoint branch May 7, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working codex codex-automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed to list buckets: Network error: dispatch failure

2 participants