Skip to content

[CT-28] Build ConfigValidationService #560

@mftee

Description

@mftee

Problem

Missing required environment variables (STELLAR_SECRET_KEY, REDIS_URL, STELLAR_HORIZON_URL) cause panics at startup with cryptic Rust unwrap errors. There is no structured validation that produces clear, actionable error messages before the server binds to a port.

Proposed Solution

Create a ConfigValidationService inside contract/module/config-validation/ that validates all required environment variables at startup.

Acceptance Criteria

  • Defines a required variables list: STELLAR_SECRET_KEY, REDIS_URL, STELLAR_HORIZON_URL, STELLAR_NETWORK
  • validate_config() function checks each variable and collects all missing ones before returning
  • If any required variable is missing, prints a formatted error listing all missing variables (not just the first) and returns an Err
  • Application main() calls validate_config() before initialising any service and exits with code 1 if validation fails
  • STELLAR_NETWORK is validated against the allowed values testnet and mainnet (case-insensitive)
  • Unit tests cover: all variables present, one variable missing, multiple variables missing, invalid STELLAR_NETWORK value
  • Implementation files live inside contract/module/config-validation/

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    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