Skip to content

fix: validate server host configuration#57

Open
echobt wants to merge 1 commit intomainfrom
fix/issue-184
Open

fix: validate server host configuration#57
echobt wants to merge 1 commit intomainfrom
fix/issue-184

Conversation

@echobt
Copy link
Copy Markdown
Contributor

@echobt echobt commented Jan 21, 2026

Description

This PR adds validation to the server_host configuration option in config.rs. Previously, any string was accepted, leading to runtime failures with unclear error messages if users provided invalid hosts like URLs or IPs with ports.

Changes

  • Added validation logic in set_server_host.
  • Rejects empty strings.
  • Rejects URLs with protocols (e.g., http://).
  • Rejects hosts containing ports (e.g., 127.0.0.1:8080), instructing users to use server_port instead.
  • Rejects strings with invalid characters.
  • Added a unit test test_server_host_validation to verify the new validation rules.

Testing

  • Added new test case test_server_host_validation which verifies that:
    • Valid hosts (localhost, 127.0.0.1) are accepted.
    • Invalid hosts (empty, URLs, IPs with ports) are rejected with appropriate error messages.
  • Ran cargo test config::tests::test_server_host_validation successfully.

Closes #184

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