HKUDS/nanobot · error · ConfigLoadError

Found missing environment variable reference(s).

Error message

Found {len(missing)} missing environment variable reference(s).

What it means

In resolve_config_env_vars, at least one ${VAR} reference in the config points to an environment variable that is not set. The walk collects all missing references into ConfigIssues (kind missing_env) so the user sees every variable to define at once; the inputs at fault are the unset variable names listed in the issues.

Solutions

  1. Export each listed environment variable before starting nanobot
  2. Replace ${VAR} in config.json with a literal value if the secret is static
  3. Remove stale ${VAR} references for variables no longer used
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at nanobot/config/loader.py:209 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of HKUDS/nanobot@42f37dc4c0 (2026-08-26). Data as JSON: /api/errors/3c31077bfc6165c6. Report an issue: GitHub.

Appendix: source

Thrown at nanobot/config/loader.py:209


_ENV_REF_PATTERN = re.compile(r"\$\{([A-Za-z_][A-Za-z0-9_]*)\}")


def resolve_config_env_vars(
    config: Config,
    *,
    config_path: Path | None = None,
) -> Config:
    """Return *config* with ``${VAR}`` env-var references resolved.

    Walks in place so fields declared with ``exclude=True`` survive;
    returns the same instance when no references are present.
    Raises ``ConfigLoadError`` if a referenced variable is not set.
    """
    missing = tuple(_missing_env_issues(config))
    if missing:
        raise ConfigLoadError(
            config_path or get_config_path(),
            kind="missing_env",
            summary=f"Found {len(missing)} missing environment variable reference(s).",
            issues=missing,
        )
    return _resolve_in_place(config)


@overload
def resolve_env_refs(value: str) -> str: ...


@overload
def resolve_env_refs(value: object) -> object: ...


def resolve_env_refs(value: object) -> object:
    """Resolve ``${VAR}`` references in a single string, leniently.

View on GitHub (pinned to 42f37dc4c0)