calesthio/OpenMontage · error · ValueError

ARK_CNY_PER_USD must be a finite number greater than 0

Error message

ARK_CNY_PER_USD must be a finite number greater than 0

What it means

First branch of `_get_cny_per_usd()`: the `ARK_CNY_PER_USD` environment variable (exchange-rate override for converting CNY pricing to USD, default "7.2") could not be parsed as a float — TypeError/ValueError from `float(...)`. Typically this means the variable holds a non-numeric string such as "7.2 CNY", an empty-ish value, or embedded whitespace/symbols.

Source

Thrown at tools/video/seedance_ark.py:452

            value = float(raw)
        except (TypeError, ValueError) as exc:
            raise ValueError(
                "custom_price_cny_per_million_tokens must be a finite "
                "number greater than 0"
            ) from exc
        if not math.isfinite(value) or value <= 0:
            raise ValueError(
                "custom_price_cny_per_million_tokens must be a finite "
                "number greater than 0"
            )
        return value

    @staticmethod
    def _get_cny_per_usd() -> float:
        try:
            value = float(os.environ.get("ARK_CNY_PER_USD", "7.2"))
        except (TypeError, ValueError) as exc:
            raise ValueError(
                "ARK_CNY_PER_USD must be a finite number greater than 0"
            ) from exc
        if not math.isfinite(value) or value <= 0:
            raise ValueError("ARK_CNY_PER_USD must be a finite number greater than 0")
        return value

    def estimate_runtime(self, inputs: dict[str, Any]) -> float:
        _, variant = self._resolve_model(inputs)
        return 90.0 if variant in {"fast", "mini"} else 180.0

    def dry_run(self, inputs: dict[str, Any]) -> dict[str, Any]:
        """Validate and estimate locally; never submit Ark's paid POST."""
        action = str(inputs.get("task_action", "generate"))
        result: dict[str, Any] = {
            "tool": self.name,
            "task_action": action,
            "status": self.get_status().value,
            "would_execute": False,

View on GitHub (pinned to 95e1c3d0ab)

Solutions

  1. Set the variable to a plain decimal number: `ARK_CNY_PER_USD=7.2`
  2. Unset it to fall back to the built-in default of 7.2
  3. Check the .env line for trailing spaces, quotes, inline comments, or unit suffixes

Example fix

# before
ARK_CNY_PER_USD="7.2 CNY"
# after
ARK_CNY_PER_USD=7.2
Defensive patterns

Strategy: validation

Validate before calling

import os
raw = os.environ.get("ARK_CNY_PER_USD", "7.2")
try:
    rate = float(raw)
except (TypeError, ValueError) as e:
    raise ValueError(f"ARK_CNY_PER_USD={raw!r} is not a number") from e

Type guard

def env_rate_is_numeric() -> bool:
    try:
        float(os.environ.get("ARK_CNY_PER_USD", "7.2"))
        return True
    except (TypeError, ValueError):
        return False

Prevention

When it happens

Trigger: Exporting `ARK_CNY_PER_USD="7.1元"` or `"~7.2"`; a .env entry with stray characters or comments glued on; a value that is a bare hyphen or letters.

Common situations: Hand-edited .env files with units; copy-paste from a financial site including currency symbols or thousand separators; CI secrets store holding a malformed value.

Related errors


AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15). Data as JSON: /api/errors/52d8448e9fbc1259. Report an issue: GitHub.