{"record":{"id":"f9106e4331489b34","repo":"TheAlgorithms/Python","slug":"the-parameter-bwt-string-must-not-be-empty","errorCode":null,"errorMessage":"The parameter bwt_string must not be empty.","messagePattern":"The parameter bwt_string must not be empty\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"data_compression/burrows_wheeler.py","lineNumber":142,"sourceCode":"    of cast to int.\n    >>> reverse_bwt(\"mnpbnnaaaaaa\", -1)\n    Traceback (most recent call last):\n        ...\n    ValueError: The parameter idx_original_string must not be lower than 0.\n    >>> reverse_bwt(\"mnpbnnaaaaaa\", 12) # doctest: +NORMALIZE_WHITESPACE\n    Traceback (most recent call last):\n        ...\n    ValueError: The parameter idx_original_string must be lower than\n    len(bwt_string).\n    >>> reverse_bwt(\"mnpbnnaaaaaa\", 11.0)\n    'panamabanana'\n    >>> reverse_bwt(\"mnpbnnaaaaaa\", 11.4)\n    'panamabanana'\n    \"\"\"\n    if not isinstance(bwt_string, str):\n        raise TypeError(\"The parameter bwt_string type must be str.\")\n    if not bwt_string:\n        raise ValueError(\"The parameter bwt_string must not be empty.\")\n    try:\n        idx_original_string = int(idx_original_string)\n    except ValueError:\n        raise TypeError(\n            \"The parameter idx_original_string type must be int or passive\"\n            \" of cast to int.\"\n        )\n    if idx_original_string < 0:\n        raise ValueError(\"The parameter idx_original_string must not be lower than 0.\")\n    if idx_original_string >= len(bwt_string):\n        raise ValueError(\n            \"The parameter idx_original_string must be lower than len(bwt_string).\"\n        )\n\n    ordered_rotations = [\"\"] * len(bwt_string)\n    for _ in range(len(bwt_string)):\n        for i in range(len(bwt_string)):\n            ordered_rotations[i] = bwt_string[i] + ordered_rotations[i]","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/data_compression/burrows_wheeler.py#L124-L160","documentation":"Raised by reverse_bwt() in data_compression/burrows_wheeler.py when bwt_string is a str but empty. The inverse BWT needs at least one character to reconstruct rotations, so empty input is rejected right after the type check.","triggerScenarios":"Calling reverse_bwt('', 0), or passing an empty string after slicing/trimming a payload, e.g. reverse_bwt(data.split('\\x00')[0], idx) when the split yields ''.","commonSituations":"Decoding a corrupted or truncated compressed payload, handling an empty file/stream chunk, or a pipeline bug that passes an empty placeholder instead of the real BWT output.","solutions":["Check the payload is non-empty before inverting: if bwt_str: reverse_bwt(bwt_str, idx).","Investigate why the BWT string is empty — usually upstream data loss or truncation, since bwt_transform() never returns an empty bwt_string for valid input.","Treat empty input as a data-integrity error in your pipeline rather than silently skipping."],"exampleFix":"# before\nplain = reverse_bwt(bwt_str, idx)  # bwt_str == ''\n\n# after\nif not bwt_str:\n    raise ValueError('corrupt payload: empty BWT string')\nplain = reverse_bwt(bwt_str, idx)","handlingStrategy":"validation","validationCode":"if not bwt_string:\n    raise ValueError('corrupt payload: empty BWT string')\nplain = reverse_bwt(bwt_string, idx)","typeGuard":null,"tryCatchPattern":"try:\n    plain = reverse_bwt(bwt_string, idx)\nexcept ValueError:\n    plain = ''  # treat as empty original","preventionTips":["Verify payload integrity (length/checksum) before decoding","An empty BWT string always means upstream data loss"],"tags":["value-validation","burrows-wheeler","empty-input","compression"],"backgroundTag":null,"analyzedSha":"f5988cc09713315817df6a7e327e258013a94440","analyzedAt":"2026-08-14T17:30:07.041Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}