Skip to content

Validate config.yml on Server Startup #33

Description

@adarshm11

Summary

config.yml is currently loaded without any validation. Missing or malformed fields silently cause repos to misbehave or produce cryptic runtime errors during a deployment. We should validate the config at startup and fail fast with a clear error message.

Problem

If a user adds a new repo entry to config.yml and forgets a required field (e.g. branch, path, or compose_file), the server starts without complaint. The error only surfaces when the first webhook arrives — often in the middle of a deployment — making it hard to debug.

Proposed Solution

Add a validate_config(config: dict) function that runs once at startup before the server begins accepting requests. It should:

  1. Check that each repo entry has all required fields: name, path, branch.
  2. Verify that each path exists on disk.
  3. Warn (but don't fail) for unknown/unrecognized keys that might be typos (e.g. brach instead of branch).
  4. Print a clear, actionable error and exit with a non-zero code on any validation failure.
REQUIRED_REPO_FIELDS = {"name", "path", "branch"}

def validate_config(config):
    for repo in config.get("repos", []):
        missing = REQUIRED_REPO_FIELDS - repo.keys()
        if missing:
            raise SystemExit(f"[config] Repo '{repo.get('name', '?')}' is missing fields: {missing}")
        if not os.path.isdir(repo["path"]):
            raise SystemExit(f"[config] Path does not exist for repo '{repo['name']}': {repo['path']}")

Acceptance Criteria

  • Server exits with a descriptive error if any required field is missing from a repo entry
  • Server exits with a descriptive error if a configured path does not exist on disk
  • Unknown top-level keys produce a warning log but do not exit
  • All existing valid config files continue to work without changes

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions