{"record":{"id":"ed5a1e280abdfc7b","repo":"xai-org/x-algorithm","slug":"batch-missing-action-multihot-column","errorCode":null,"errorMessage":"batch missing {ACTION_MULTIHOT_COLUMN}","messagePattern":"batch missing (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"phoenix/xrex/data/conversion_labels.py","lineNumber":91,"sourceCode":"\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 = (\n        mh.flatten()\n        .flatten()\n        .to_numpy(zero_copy_only=False)\n        .astype(np.bool_)\n        .reshape(batch.num_rows, seq_len, vocab)\n        .copy()\n    )\n    mask_name = next(\n        (n for n in (\"newEventMask\", \"newEventMaskSeq\") if n in batch.schema.names), None\n    )\n    if mask_name is None:\n        raise ValueError(\"batch missing newEventMask; conversion-label folding is candidate-only\")\n    mask_col = batch.column(mask_name)\n    is_candidate = (","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/phoenix/xrex/data/conversion_labels.py#L73-L109","documentation":"fold_action_delays_into_multihot() folds per-action delay columns into the existing ACTION_MULTIHOT_COLUMN of the batch. If action delay columns are present but the multi-hot column is missing from the batch schema, there is nothing to fold into, so it raises ValueError naming the missing column.","triggerScenarios":"Producer path with include_action_delay_columns=True on a batch schema that predates the multi-hot feature; a batch where the multi-hot column was renamed or dropped upstream; delay columns attached but multi-hot column filtered out by a column projection.","commonSituations":"Training on older datasets lacking the multi-hot column; column pruning config that excludes ACTION_MULTIHOT_COLUMN.","solutions":["Ensure the source batch files contain the multi-hot column (regenerate or use newer data).","Remove the projection/filter that drops the multi-hot column before folding.","Disable action-delay folding (include_action_delay_columns=False) if multi-hot is not needed."],"exampleFix":"// before\nbatch = fold_action_delays_into_multihot(batch_wo_multihot, window_ms)  # ValueError\n\n// after\nbatch = fold_action_delays_into_multihot(batch_with_multihot, window_ms)","handlingStrategy":"validation","validationCode":"has_multihot = ACTION_MULTIHOT_COLUMN in batch.schema.names\nhas_action_cols = any(n.startswith(ACTION_DELAY_PREFIX) for n in batch.schema.names)\nassert not (has_action_cols and not has_multihot), 'cannot fold without multi-hot'","typeGuard":"def can_fold(batch) -> bool:\n    names = batch.schema.names\n    return (ACTION_MULTIHOT_COLUMN in names\n            and any(n.startswith('action_delay_') for n in names))","tryCatchPattern":"try:\n    batch = fold_action_delays_into_multihot(batch, w)\nexcept ValueError as e:\n    logger.error('folding failed: %s', e); raise","preventionTips":["Assert required columns exist right after reading the first batch of a run.","Keep column projections from dropping the multi-hot column when action delays are enabled."],"tags":["schema","conversion-labels","multihot","validation"],"backgroundTag":"missing-required-column","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}