Skip to content

[Bug]: No config validation after LoadConfig() allows invalid runtime state #104

Description

@mrhillsman

Bug Description

LoadConfig() in internal/config/config.go assembles a Config struct from flags, environment variables, config file, and defaults, but performs no semantic validation on the result. Invalid values pass through and are only caught later (or not at all) at use sites:

  • Empty namespace — produces K8s resources with no namespace, which either fail at the API or land in the default namespace
  • Invalid memory format — caught later by resource.ParseQuantity in BuildVMSpec, but the error message lacks config-level context
  • Zero or negative CPU cores — silently produces a VM spec with 0 CPU cores
  • Zero or negative timeout — creates a deadline that is already in the past, causing immediate timeout failures with a misleading error

Steps to Reproduce

  1. Run virtwork run --cpu-cores 0 --timeout -1 --namespace ""
  2. Observe that LoadConfig succeeds
  3. Downstream failures occur with confusing error messages that don't point back to the invalid config

Expected Behavior

LoadConfig() should validate the assembled config and return a clear error naming the invalid field, the value it received, and what is expected. Fail fast at config load time rather than producing cascading failures downstream.

Actual Behavior

Invalid config values pass through LoadConfig silently. Failures surface later with no context about which config field caused the problem.

Command

virtwork run

Affected Files

  • internal/config/config.go:96-181LoadConfig() has no post-assembly validation

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions