{"record":{"id":"b2127ca5da2d2037","repo":"tensorflow/models","slug":"illegal-padding-value-must-be-one-of-left-rig","errorCode":null,"errorMessage":"Illegal padding value; must be one of \"left\", \"right\" or None.","messagePattern":"Illegal padding value; must be one of \"left\", \"right\" or None\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/nlp/modeling/layers/kernel_attention.py","lineNumber":73,"sourceCode":"      be divisible by the chunk_length.\n\n  Returns:\n    Padded tensor with shape[axis] divisible by chunk_length.\n  \"\"\"\n  if padding is None:\n    return tensor\n  shape = tf.shape(tensor)\n  rank = tf.rank(tensor)\n  if axis < 0:\n    axis += rank\n  axis_length = shape[axis]\n  pad_length = -axis_length % chunk_length\n  if padding == \"right\":\n    axis_paddings = [[0, pad_length]]\n  elif padding == \"left\":\n    axis_paddings = [[pad_length, 0]]\n  else:\n    raise ValueError(\n        \"Illegal padding value; must be one of \\\"left\\\", \\\"right\\\" or None.\")\n  paddings = tf.concat([\n      tf.zeros([axis, 2], dtype=tf.int32), axis_paddings,\n      tf.zeros([rank - axis - 1, 2], dtype=tf.int32)\n  ],\n                       axis=0)\n  return tf.pad(tensor, paddings)\n\n\ndef split_tensor_into_chunks(tensor, axis, chunk_length):\n  \"\"\"Reshape tensor along given axis using chunk_length.\n\n  Args:\n    tensor: Input tensor.\n    axis: Reshape tensor along this axis.\n    chunk_length: Split the axis into [axis/chunk_length, chunk_length]\n\n  Returns:","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/modeling/layers/kernel_attention.py#L55-L91","documentation":"Error \"Illegal padding value; must be one of \"left\", \"right\" or None.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/nlp/modeling/layers/kernel_attention.py:73 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}