Fix #28: Add validation for web-tail.config.toml content#96
Conversation
Added comprehensive validation for configuration file to catch common errors early during startup: Validation rules: - Required fields: source name/type/path, server name/host/port/username - Valid source types: local:file, local:docker, local:openclaw, ssh:file, ssh:docker, ssh:openclaw - Type-specific requirements: path for *:file sources, containerId for *:docker sources - SSH sources: host, port (1-65535), username, and either password or privateKeyPath - Server references: serverName must reference an existing server - Duplicate names: source and server names must be unique - Port ranges: all ports must be 1-65535 Added 21 test cases covering valid configs and all error scenarios. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
@coderabbitai review |
|
This PR broke the app for me because I only use |
|
@jkrehm can you provide a bit more info about how you use web-tail (docker or executable, what platform) and how your config file looks |
|
I use it in a Docker container where I mount the logs that I want to view into the container. Then I point at localhost. An abbreviated version of my [[servers]]
name = "local"
host = "localhost"
[[sources]]
name = "metube_cleanup"
type = "local:file"
serverName = "local"
path = "/logs/jonathan/metube_cleanup.log"and my services:
web-tail:
image: ghcr.io/mishankov/web-tail
container_name: web-tail
restart: unless-stopped
volumes:
- /home/jonathan/.log:/logs/jonathan:roAfter the validation change I had to update the servers block to: [[servers]]
name = "local"
host = "localhost"
port = 1
username = "dummy"
password = "dummy"It's not a big deal, but if there's a way to make the validation smarter, it would let me reduce the noise in my configuration. |
|
@jkrehm you do not need to use |
|
Oh sweet, that's much simpler. Thanks for the info, and thanks for a useful tool. |
Summary
web-tail.config.tomlconfiguration fileChanges
Validation Rules
local:file,local:docker,local:openclaw,ssh:file,ssh:docker,ssh:openclaw*:filesources requirepath*:dockersources requirecontainerIdhostandport(1-65535)usernamepasswordorprivateKeyPathserverNamereferences an existing serverImplementation
Validate()method toConfigstructparseConfig()after config is fully resolvedsources[0].name)Testing
config_test.gowith 21 test casesTest plan
go test ./...)Closes #28
🤖 Generated with Claude Code