{"record":{"id":"9e5dd5ac1b1b9a05","repo":"sgl-project/sglang","slug":"reference-audio-duration-bound-must-be-positive","errorCode":null,"errorMessage":"reference audio duration bound must be positive","messagePattern":"reference audio duration bound must be positive","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/reference_encoding.py","lineNumber":229,"sourceCode":"    max_duration_seconds: float | None = None,\n    start_time_seconds: float = 0.0,\n    source_sample_rate: int | None = None,\n) -> tuple[torch.Tensor, int]:\n    \"\"\"Apply the audio material chain.\n\n    Pure-audio references preserve their source rate while normalizing to\n    stereo. Video-bearing references first extract 44.1 kHz stereo PCM. The\n    audio VAE boundary then performs the single 32 kHz resample below. ffmpeg\n    writes bounded interleaved float PCM directly to stdout, avoiding a\n    temporary lossless file plus a second decode.\n    \"\"\"\n\n    import numpy as np\n\n    if max_duration_seconds is not None:\n        max_duration_seconds = float(max_duration_seconds)\n        if not math.isfinite(max_duration_seconds) or max_duration_seconds <= 0:\n            raise ValueError(\"reference audio duration bound must be positive\")\n    start_time_seconds = float(start_time_seconds)\n    if not math.isfinite(start_time_seconds) or start_time_seconds < 0:\n        raise ValueError(\"reference audio start time must be non-negative\")\n\n    if material_chain == \"audio\":\n        if source_sample_rate is None or int(source_sample_rate) <= 0:\n            raise ValueError(\"reference audio sample rate must be positive\")\n        source_rate = int(source_sample_rate)\n    elif material_chain in {\n        \"video.reference_preserve\",\n        \"video_audio.reference_preserve\",\n    }:\n        source_rate = 44100\n    else:\n        raise ValueError(\n            f\"unsupported MiniMax H3 audio material chain {material_chain!r}\"\n        )\n","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/reference_encoding.py#L211-L247","documentation":"When decoding reference audio with _load_waveform, an optional max_duration_seconds bound must be a positive finite float if provided. The bound caps ffmpeg decoding length for safety; non-positive or NaN/infinite bounds are rejected.","triggerScenarios":"Passing max_duration_seconds=0, a negative number, or float('nan') to minimax_h3_encode_reference_audio_rows or _load_waveform; also triggered by its tests exercising the bound.","commonSituations":"Duration computed as (end - start) going negative when the clip end precedes the start, or a config default of 0 meaning 'unbounded' but interpreted as a bound.","solutions":["If you mean 'no bound', pass None instead of 0","Compute bounds as max(0.0, end-start) plus a small epsilon, and pass None when the result is 0","Validate the config value at load time"],"exampleFix":"// before\nmax_dur = end - start  # can be 0 or negative\n\n// after\nmax_dur = (end - start) if end and end > start else None","handlingStrategy":"validation","validationCode":"import math\n\ndef valid_bound(d):\n    return d is None or (isinstance(d, (int, float)) and math.isfinite(d) and d > 0)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass None for 'unbounded', never 0","Compute bounds from end-start with a guard against non-positive results"],"tags":["minimax-h3","audio","duration-validation"],"backgroundTag":"invalid-audio-duration","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}