{"record":{"id":"00ac9803c61837ab","repo":"calesthio/OpenMontage","slug":"custom-price-cny-per-million-tokens-must-be-a-fini","errorCode":null,"errorMessage":"custom_price_cny_per_million_tokens must be a finite number greater than 0","messagePattern":"custom_price_cny_per_million_tokens must be a finite number greater than 0","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/video/seedance_ark.py","lineNumber":436,"sourceCode":"    def estimate_cost(self, inputs: dict[str, Any]) -> float:\n        cny_per_usd = self._get_cny_per_usd()\n        return round(self.estimate_cost_cny(inputs) / cny_per_usd, 4)\n\n    @staticmethod\n    def _get_custom_price(inputs: dict[str, Any], *, required: bool) -> float:\n        try:\n            raw = inputs[\"custom_price_cny_per_million_tokens\"]\n        except KeyError as exc:\n            if not required:\n                return 0.0\n            raise ValueError(\n                \"pricing is unknown for a custom Ark Endpoint/Model; \"\n                \"set custom_price_cny_per_million_tokens before a paid create\"\n            ) from exc\n        try:\n            value = float(raw)\n        except (TypeError, ValueError) as exc:\n            raise ValueError(\n                \"custom_price_cny_per_million_tokens must be a finite \"\n                \"number greater than 0\"\n            ) from exc\n        if not math.isfinite(value) or value <= 0:\n            raise ValueError(\n                \"custom_price_cny_per_million_tokens must be a finite \"\n                \"number greater than 0\"\n            )\n        return value\n\n    @staticmethod\n    def _get_cny_per_usd() -> float:\n        try:\n            value = float(os.environ.get(\"ARK_CNY_PER_USD\", \"7.2\"))\n        except (TypeError, ValueError) as exc:\n            raise ValueError(\n                \"ARK_CNY_PER_USD must be a finite number greater than 0\"\n            ) from exc","sourceCodeStart":418,"sourceCodeEnd":454,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/video/seedance_ark.py#L418-L454","documentation":"First of two identical-message branches in `_get_custom_price`: this one fires when `float(raw)` raises TypeError/ValueError, i.e. the supplied `custom_price_cny_per_million_tokens` is not parseable as a number at all — a string like `\"cheap\"`, a list, None, or similar. The second branch (error 288) covers values that parse but are non-finite or non-positive.","triggerScenarios":"Passing `custom_price_cny_per_million_tokens` as a non-numeric string (\"0.15元\"), None, a dict/list, or a bool-bearing expression that does not coerce; JSON payloads where the value arrives quoted.","commonSituations":"Config files or LLM-generated inputs that quote the number; currency symbols or units accidentally embedded in the value; templating systems substituting an empty/None placeholder.","solutions":["Pass a bare number (or numeric string) with no units or symbols: `15.0` not `\"15 CNY/MTok\"`","Validate `float(value)` in your own code before calling the tool","Check for stray quotes in JSON/YAML config where the value is defined"],"exampleFix":"# before\ninputs = {\"custom_price_cny_per_million_tokens\": \"15 CNY per Mtok\"}\n# after\ninputs = {\"custom_price_cny_per_million_tokens\": 15.0}","handlingStrategy":"validation","validationCode":"raw = inputs.get(\"custom_price_cny_per_million_tokens\")\nif raw is not None:\n    try:\n        float(raw)\n    except (TypeError, ValueError) as e:\n        raise ValueError(f\"price {raw!r} is not numeric\") from e","typeGuard":"def is_numeric_price(v: object) -> bool:\n    try:\n        return float(v) == float(v)  # NaN check via self-equality\n    except (TypeError, ValueError):\n        return False","tryCatchPattern":"try:\n    result = ark.execute(inputs)\nexcept ValueError as e:\n    if \"finite number\" in str(e):\n        raise ValueError(f\"bad custom_price input: {inputs.get('custom_price_cny_per_million_tokens')!r}\") from e\n    raise","preventionTips":["Pass prices as bare JSON numbers, never quoted strings with units","Lint your job-config schema for numeric fields"],"tags":["seedance","ark","pricing","input-validation","type-error"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}