{"record":{"id":"4c2f65e4ebe89ef5","repo":"FuelLabs/fuels-ts","slug":"invalid-input-parameters-4c2f65","errorCode":"INVALID_INPUT_PARAMETERS","errorMessage":"Invalid walletIndex ${config.walletIndex}; wallets array contains ${wallets.length} elements.","messagePattern":"Invalid walletIndex (.+?); wallets array contains (.+?) elements\\.","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/contract/src/test-utils/launch-test-node.ts","lineNumber":130,"sourceCode":"function getFuelCoreArgs<TFactories extends DeployContractConfig[]>(\n  nodeOptions: LaunchTestNodeOptions<TFactories>['nodeOptions']\n) {\n  const envArgs = process.env.DEFAULT_FUEL_CORE_ARGS\n    ? process.env.DEFAULT_FUEL_CORE_ARGS.split(' ')\n    : undefined;\n\n  return nodeOptions?.args ?? envArgs;\n}\n\nfunction getWalletForDeployment(config: DeployContractConfig, wallets: WalletUnlocked[]) {\n  if (!('walletIndex' in config) || !config.walletIndex) {\n    return wallets[0];\n  }\n\n  const validWalletIndex = config.walletIndex >= 0 && config.walletIndex < wallets.length;\n\n  if (!validWalletIndex) {\n    throw new FuelError(\n      FuelError.CODES.INVALID_INPUT_PARAMETERS,\n      `Invalid walletIndex ${config.walletIndex}; wallets array contains ${wallets.length} elements.`\n    );\n  }\n\n  return wallets[config.walletIndex];\n}\n\nexport async function launchTestNode<const TFactories extends DeployContractConfig[]>({\n  providerOptions = {},\n  walletsConfig = {},\n  nodeOptions = {},\n  contractsConfigs,\n}: Partial<LaunchTestNodeOptions<TFactories>> = {}): Promise<LaunchTestNodeReturn<TFactories>> {\n  const snapshotConfig = getChainSnapshot(nodeOptions);\n  const args = getFuelCoreArgs(nodeOptions);\n  const { provider, wallets, cleanup } = await setupTestProviderAndWallets({\n    walletsConfig,","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/contract/src/test-utils/launch-test-node.ts#L112-L148","documentation":"Thrown by getWalletForDeployment() (packages/contract/src/test-utils/launch-test-node.ts:130) when config.walletIndex is negative or greater than or equal to the number of wallets generated by the test node launcher. This is a test-utility function that selects which wallet from the generated wallet array should be used to deploy a contract in a test scenario.","triggerScenarios":"In launchTestNode, passing a contractsConfigs entry with walletIndex set to a value >= the number of wallets in walletsConfig (or < 0), while walletsConfig.count (default 10) determines how many wallets are generated. For example, requesting walletIndex 10 when only 10 wallets exist (indices 0-9).","commonSituations":"Setting walletIndex beyond the default wallet count; reducing walletsConfig.count without updating walletIndex references; off-by-one errors assuming 1-indexed wallets (they are 0-indexed); copy-pasting a config that referenced a higher wallet index.","solutions":["Ensure walletIndex is 0-indexed and less than walletsConfig.count (default 10).","Increase walletsConfig.count to accommodate the desired walletIndex.","Omit walletIndex to default to wallets[0]."],"exampleFix":"// before\nconst { contracts } = await launchTestNode({\n  walletsConfig: { count: 5 },\n  contractsConfigs: [{ factory, walletIndex: 7 }],\n});\n\n// after\nconst { contracts } = await launchTestNode({\n  walletsConfig: { count: 10 },\n  contractsConfigs: [{ factory, walletIndex: 7 }],\n});","handlingStrategy":"validation","validationCode":"const walletCount = 10; // must match walletsConfig.count\nconst walletIndex = config.walletIndex ?? 0;\nif (walletIndex < 0 || walletIndex >= walletCount) {\n  throw new Error(`walletIndex ${walletIndex} out of range [0, ${walletCount - 1}]`);\n}\n// Use in contractsConfigs","typeGuard":"function isValidWalletIndex(index: number, walletCount: number): boolean {\n  return Number.isInteger(index) && index >= 0 && index < walletCount;\n}","tryCatchPattern":null,"preventionTips":["Remember walletIndex is 0-indexed; valid range is [0, walletsConfig.count - 1].","Set walletsConfig.count high enough to accommodate all walletIndex references.","Omit walletIndex to default to wallets[0] when the specific wallet doesn't matter.","This is a test utility — only relevant in launchTestNode() contractsConfigs."],"tags":["test-utils","deployment","wallet","input-validation","configuration"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}