{"record":{"id":"be6fa7ae0aa55547","repo":"FuelLabs/fuels-ts","slug":"invalid-word-list","errorCode":"INVALID_WORD_LIST","errorMessage":"Expected word list length of 2048, but got ${wordlist.length}.","messagePattern":"Expected word list length of 2048, but got (.+?)\\.","errorType":"validation","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/account/src/mnemonic/mnemonic.ts","lineNumber":24,"sourceCode":"\nimport { english } from '../wordlists';\n\nimport type { MnemonicPhrase } from './utils';\nimport { entropyToMnemonicIndices, getWords, getPhrase, mnemonicWordsToEntropy } from './utils';\n\n//\n// Constants\n//\n// \"Bitcoin seed\"\nconst MasterSecret = toUtf8Bytes('Bitcoin seed');\n// 4 byte: version bytes (mainnet: 0x0488B21E public, 0x0488ADE4 private; testnet: 0x043587CF public, 0x04358394 private)\nconst MainnetPRV = '0x0488ade4';\nconst TestnetPRV = '0x04358394';\nexport const MNEMONIC_SIZES = [12, 15, 18, 21, 24];\n\nfunction assertWordList(wordlist: Array<string>) {\n  if (wordlist.length !== 2048) {\n    throw new FuelError(\n      ErrorCode.INVALID_WORD_LIST,\n      `Expected word list length of 2048, but got ${wordlist.length}.`\n    );\n  }\n}\n\nfunction assertEntropy(entropy: BytesLike) {\n  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {\n    throw new FuelError(\n      ErrorCode.INVALID_ENTROPY,\n      `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`\n    );\n  }\n}\n\nfunction assertMnemonic(words: Array<string>) {\n  if (!MNEMONIC_SIZES.includes(words.length)) {\n    const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/account/src/mnemonic/mnemonic.ts#L6-L42","documentation":"Thrown by assertWordList (called from the Mnemonic constructor and Mnemonic.entropyToMnemonic) when the supplied wordlist does not contain exactly 2048 entries. BIP-39 wordlists are fixed-size (2048 words = 11-bit indices); any other length breaks mnemonic-to-entropy/entropy-to-mnemonic indexing. The default English list is used if no wordlist is passed.","triggerScenarios":"Constructing new Mnemonic(myWords) with myWords.length !== 2048, or calling Mnemonic.entropyToMnemonic(entropy, customList) / mnemonicToEntropy with a short/long list. Not triggered when relying on the default English wordlist.","commonSituations":"Passing a truncated or extended wordlist, using a non-BIP-39 word collection, accidentally slicing the list, or loading a wordlist file that failed to parse into 2048 entries.","solutions":["Omit the wordlist argument to use the default BIP-39 English list.","If supplying a custom list (e.g. another language), ensure it is the official 2048-word BIP-39 list for that language, unmodified.","Validate wordlist.length === 2048 before constructing the Mnemonic."],"exampleFix":"// before\nconst m = new Mnemonic(myTruncatedWords);\n\n// after\nconst m = new Mnemonic(); // uses default English BIP-39 list","handlingStrategy":"validation","validationCode":"function isValidWordlist(list: string[]): boolean {\n  return Array.isArray(list) && list.length === 2048;\n}\n\n// Prefer the default; only override with a known-good 2048-word BIP-39 list\nconst m = new Mnemonic();\n// or:\nif (isValidWordlist(myList)) new Mnemonic(myList);","typeGuard":"function isBip39Wordlist(list: unknown): list is string[] {\n  return Array.isArray(list) && list.length === 2048;\n}","tryCatchPattern":"try {\n  const m = new Mnemonic(customList);\n} catch (e) {\n  if (e instanceof FuelError && e.code === ErrorCode.INVALID_WORD_LIST) {\n    // fall back to the default English wordlist\n    const m = new Mnemonic();\n  } else throw e;\n}","preventionTips":["Omit the wordlist argument to use the default BIP-39 English list.","Only override with the official 2048-word BIP-39 list for the target language.","Validate list.length === 2048 before constructing a Mnemonic."],"tags":["mnemonic","bip39","wordlist","validation"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}