{"record":{"id":"f03354d0e959fef8","repo":"xai-org/x-algorithm","slug":"name-delay-rows-mat-shape-0-batch-rows-b","errorCode":null,"errorMessage":"{name}: delay rows {mat.shape[0]} != batch rows {batch.num_rows}","messagePattern":"(.+?): delay rows (.+?) != batch rows (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"phoenix/xrex/data/conversion_labels.py","lineNumber":77,"sourceCode":"        raise ValueError(\n            f\"sidecar {sidecar_path} missing column(s) {missing}; available: {schema_names}\"\n        )\n    t = pq.read_table(sidecar_path, columns=columns)\n    out: dict[str, np.ndarray] = {}\n    for name in columns:\n        col = t.column(name).combine_chunks()\n        if isinstance(col, pa.ChunkedArray):\n            col = col.chunk(0)\n        seq_len = col.type.list_size\n        flat = col.flatten().to_numpy(zero_copy_only=False).astype(np.int64)\n        out[name] = flat.reshape(len(col), seq_len)\n    return out\n\n\ndef attach_delays(batch: pa.RecordBatch, delays: dict[str, np.ndarray]) -> pa.RecordBatch:\n    for name, mat in delays.items():\n        if mat.shape[0] != batch.num_rows:\n            raise ValueError(f\"{name}: delay rows {mat.shape[0]} != batch rows {batch.num_rows}\")\n        arr = pa.FixedSizeListArray.from_arrays(\n            pa.array(mat.reshape(-1), type=pa.int64()), mat.shape[1]\n        )\n        batch = batch.append_column(name, arr)\n    return batch\n\n\ndef fold_action_delays_into_multihot(batch: pa.RecordBatch, window_ms: int) -> pa.RecordBatch:\n    action_cols = [n for n in batch.schema.names if n.startswith(ACTION_DELAY_PREFIX)]\n    if not action_cols:\n        return batch\n    col_idx = batch.schema.get_field_index(ACTION_MULTIHOT_COLUMN)\n    if col_idx < 0:\n        raise ValueError(f\"batch missing {ACTION_MULTIHOT_COLUMN}\")\n    mh = batch.column(col_idx)\n    seq_len = mh.type.list_size\n    vocab = mh.type.value_type.list_size\n    bits = (","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/phoenix/xrex/data/conversion_labels.py#L59-L95","documentation":"attach_delays() appends each delay column from the sidecar to a RecordBatch, first asserting row-count alignment: the sidecar matrix must have exactly as many rows as the batch. A mismatch means the sidecar was generated for a different version of the batch file (different row count), so delays cannot be attached.","triggerScenarios":"Sidecar regenerated after the batch parquet was rewritten with a different row count; batch truncated/rewritten by a reprocessing job while sidecar stayed stale; reading a batch and sidecar from different runs.","commonSituations":"Partially re-processed topics where batch files were replaced but labels were not; race between writer jobs producing batches and label jobs.","solutions":["Regenerate the conversion-label sidecar from the current batch file so row counts match.","Delete stale sidecars and rerun the labeling pipeline for the affected partition.","Skip conversion-label columns for the corrupted batch until it is relabeled."],"exampleFix":"// before\nbatch2 = attach_delays(batch, stale_delays)  # ValueError: rows 1000 != 1200\n\n// after\nstale_delays = rerun_labeling(batch_path)  # regenerate sidecar\nbatch2 = attach_delays(batch, stale_delays)","handlingStrategy":"validation","validationCode":"if any(m.shape[0] != batch.num_rows for m in delays.values()):\n    raise SystemExit('stale sidecar: regenerate labels before attach')","typeGuard":null,"tryCatchPattern":"try:\n    batch = attach_delays(batch, delays)\nexcept ValueError as e:\n    logger.warning('row mismatch, skipping delay attach: %s', e)\n    # fall back to batch without delay columns","preventionTips":["Write row counts (or batch id hashes) into sidecar metadata and verify before attach.","Relabel partitions whenever batch files are rewritten."],"tags":["row-count-mismatch","conversion-labels","data-integrity"],"backgroundTag":"data-shape-mismatch","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}