{"record":{"id":"d365fe62c3c5877a","repo":"xai-org/x-algorithm","slug":"window-ms-must-be-0-got-window-ms","errorCode":null,"errorMessage":"window_ms must be >= 0, got {window_ms}","messagePattern":"window_ms must be >= 0, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"phoenix/xrex/data/conversion_labels.py","lineNumber":140,"sourceCode":"        delays = (\n            delays_col.flatten()\n            .to_numpy(zero_copy_only=False)\n            .astype(np.int64)\n            .reshape(batch.num_rows, delays_col.type.list_size)\n        )\n        if delays.shape[1] != seq_len:\n            raise ValueError(f\"{name}: seq len {delays.shape[1]} != multi-hot {seq_len}\")\n        bits[:, :, idx] = np.where(\n            is_candidate, delays_to_labels(delays, window_ms), bits[:, :, idx]\n        )\n    inner = pa.FixedSizeListArray.from_arrays(pa.array(bits.reshape(-1)), vocab)\n    outer = pa.FixedSizeListArray.from_arrays(inner, seq_len)\n    return batch.set_column(col_idx, batch.schema.field(col_idx), outer)\n\n\ndef delays_to_labels(delays: np.ndarray, window_ms: int) -> np.ndarray:\n    if window_ms < 0:\n        raise ValueError(f\"window_ms must be >= 0, got {window_ms}\")\n    return (delays >= 0) & (delays <= window_ms)\n","sourceCodeStart":122,"sourceCodeEnd":142,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/phoenix/xrex/data/conversion_labels.py#L122-L142","documentation":"delays_to_labels() converts raw int64 delay values into boolean labels: delay in [-?, window_ms] via (delays >= 0) & (delays <= window_ms). A negative window_ms is nonsensical (it would make the label always false), so it is rejected up front with ValueError.","triggerScenarios":"Calling delays_to_labels(delays, window_ms=-1); passing a window computed as end-start that underflowed negative; config typo making conversion_window_ms negative; fold_action_delays_into_multihot propagating a bad window_ms.","commonSituations":"Misconfigured hyperparameter (sign error); arithmetic producing negative deltas; CLI arg parsing '-w 3600' vs intended positive value.","solutions":["Set window_ms to a non-negative integer (milliseconds).","Validate/compute the window with max(0, end - start) if derived from timestamps.","Add a config assertion before training starts."],"exampleFix":"// before\nlabels = delays_to_labels(delays, window_ms=duration_ms_negative)\n\n// after\nlabels = delays_to_labels(delays, window_ms=max(0, duration_ms))","handlingStrategy":"validation","validationCode":"if not isinstance(window_ms, int) or window_ms < 0:\n    raise SystemExit(f'invalid window_ms: {window_ms!r}')","typeGuard":"def is_valid_window(w) -> bool:\n    return isinstance(w, int) and w >= 0","tryCatchPattern":"try:\n    labels = delays_to_labels(delays, window_ms)\nexcept ValueError as e:\n    raise ConfigError(str(e)) from e","preventionTips":["Validate window_ms once in config loading with pydantic/JSON-schema constraints.","Compute windows as max(0, end_ms - start_ms)."],"tags":["argument-validation","window","conversion-labels"],"backgroundTag":"invalid-argument-value","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}