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:
- Check that each repo entry has all required fields:
name, path, branch.
- Verify that each
path exists on disk.
- Warn (but don't fail) for unknown/unrecognized keys that might be typos (e.g.
brach instead of branch).
- 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
Summary
config.ymlis 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.ymland forgets a required field (e.g.branch,path, orcompose_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:name,path,branch.pathexists on disk.brachinstead ofbranch).Acceptance Criteria
pathdoes not exist on disk