Skip to content

Fix #28: Add validation for web-tail.config.toml content#96

Merged
mishankov merged 1 commit into
mainfrom
issue-28-validate-config
Feb 26, 2026
Merged

Fix #28: Add validation for web-tail.config.toml content#96
mishankov merged 1 commit into
mainfrom
issue-28-validate-config

Conversation

@mishankov
Copy link
Copy Markdown
Owner

Summary

  • Implemented comprehensive validation for web-tail.config.toml configuration file
  • Validation runs during config parsing and catches common errors early
  • Added extensive test coverage with 21 test cases

Changes

Validation Rules

  • Required fields: Validates that mandatory fields are present for sources and servers
  • Source types: Ensures type is one of: local:file, local:docker, local:openclaw, ssh:file, ssh:docker, ssh:openclaw
  • Type-specific validation:
    • *:file sources require path
    • *:docker sources require containerId
  • SSH sources require:
    • host and port (1-65535)
    • username
    • Either password or privateKeyPath
  • Server references: Validates that serverName references an existing server
  • Uniqueness: Source and server names must be unique
  • Port ranges: All ports must be between 1 and 65535

Implementation

  • Added Validate() method to Config struct
  • Called from parseConfig() after config is fully resolved
  • Returns descriptive error messages with field paths (e.g., sources[0].name)

Testing

  • Created config_test.go with 21 test cases
  • Tests cover both valid configurations and all error scenarios
  • All tests pass successfully

Test plan

  • Unit tests pass (go test ./...)
  • Validation correctly rejects invalid configs
  • Validation accepts valid configs
  • Error messages are clear and actionable

Closes #28

🤖 Generated with Claude Code

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>
@mishankov
Copy link
Copy Markdown
Owner Author

@coderabbitai review

@mishankov mishankov merged commit 1777fdd into main Feb 26, 2026
6 checks passed
@mishankov mishankov deleted the issue-28-validate-config branch February 26, 2026 19:51
@jkrehm
Copy link
Copy Markdown

jkrehm commented Apr 18, 2026

This PR broke the app for me because I only use local:file and it's requiring port, username, and password/private key for my local server. I can put dummy info in for those properties, but it doesn't seem like that should be necessary.

@mishankov
Copy link
Copy Markdown
Owner Author

@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
Just tested on code from main and macos executable from latest release with default config from repo and validation was happy

@jkrehm
Copy link
Copy Markdown

jkrehm commented Apr 18, 2026

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 web-tail.config.toml file (only included one source):

[[servers]]
name = "local"
host = "localhost"

[[sources]]
name = "metube_cleanup"
type = "local:file"
serverName = "local"
path = "/logs/jonathan/metube_cleanup.log"

and my docker-compose.yml

services:
  web-tail:
    image: ghcr.io/mishankov/web-tail
    container_name: web-tail
    restart: unless-stopped
    volumes:
      - /home/jonathan/.log:/logs/jonathan:ro

After 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.

@mishankov
Copy link
Copy Markdown
Owner Author

@jkrehm you do not need to use servers for local:* configurations. It useful only for ssh:* configurations, so you can share ssh configurations across sources.
You can drop servers block and serverName key in source completely

@jkrehm
Copy link
Copy Markdown

jkrehm commented Apr 19, 2026

Oh sweet, that's much simpler. Thanks for the info, and thanks for a useful tool.

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.

Validate web-tail.config.toml content

2 participants