{"record":{"id":"3eb9e7ac4e0693dd","repo":"FuelLabs/fuels-ts","slug":"invalid-transaction-input-3eb9e7","errorCode":"INVALID_TRANSACTION_INPUT","errorMessage":"Invalid transaction input type: ${type}.","messagePattern":"Invalid transaction input type: (.+?)\\.","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/transactions/src/coders/input.ts","lineNumber":380,"sourceCode":"    parts.push(new NumberCoder('u8', { padToWordSize: true }).encode(value.type));\n\n    const { type } = value;\n\n    switch (type) {\n      case InputType.Coin: {\n        parts.push(new InputCoinCoder().encode(value));\n        break;\n      }\n      case InputType.Contract: {\n        parts.push(new InputContractCoder().encode(value));\n        break;\n      }\n      case InputType.Message: {\n        parts.push(new InputMessageCoder().encode(value));\n        break;\n      }\n      default: {\n        throw new FuelError(\n          ErrorCode.INVALID_TRANSACTION_INPUT,\n          `Invalid transaction input type: ${type}.`\n        );\n      }\n    }\n\n    return concat(parts);\n  }\n\n  decode(data: Uint8Array, offset: number): [Input, number] {\n    let decoded;\n    let o = offset;\n\n    [decoded, o] = new NumberCoder('u8', { padToWordSize: true }).decode(data, o);\n    const type = decoded as InputType;\n    switch (type) {\n      case InputType.Coin: {\n        [decoded, o] = new InputCoinCoder().decode(data, o);","sourceCodeStart":362,"sourceCodeEnd":398,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/transactions/src/coders/input.ts#L362-L398","documentation":"Thrown by InputCoder.encode() when input.type is not one of the supported InputType enum values (Coin=0, Contract=1, Message=2). The encode switch has no case for the given type, so it falls to default. This signals an input object constructed with an out-of-range or unrecognized type.","triggerScenarios":"Manually building an Input object with type set to an invalid number/string; passing a partial input missing a valid type; feeding a transaction request whose inputs were assembled from unvalidated data.","commonSituations":"Constructing raw transaction inputs without using the SDK builders; version skew where a new input type exists on-chain but the SDK does not support it; assigning type: 3+ (no such input type).","solutions":["Use the InputType enum (import { InputType }) and the SDK's input factories rather than literal numbers.","Validate each input.type is one of InputType.Coin | Contract | Message before encoding.","Upgrade @fuel-ts/transactions if a newer input type is required."],"exampleFix":"// before\nconst input = { type: 9, ... };\n\n// after\nimport { InputType } from '@fuel-ts/transactions';\nconst input = { type: InputType.Coin, ... };","handlingStrategy":"type-guard","validationCode":"import { InputType } from '@fuel-ts/transactions';\n\nconst VALID_INPUT_TYPES = new Set([InputType.Coin, InputType.Contract, InputType.Message]);\nfunction isValidInputType(t: number): boolean {\n  return VALID_INPUT_TYPES.has(t as InputType);\n}\n\ninputs.forEach(i => { if (!isValidInputType(i.type)) throw new Error(`Bad input type ${i.type}`); });","typeGuard":"import { InputType } from '@fuel-ts/transactions';\nfunction isValidInput(i: { type: number }): boolean {\n  return [InputType.Coin, InputType.Contract, InputType.Message].includes(i.type as InputType);\n}","tryCatchPattern":"try {\n  inputCoder.encode(value);\n} catch (e) {\n  if (e instanceof FuelError && e.code === ErrorCode.INVALID_TRANSACTION_INPUT) {\n    // coerce input.type to a valid InputType enum member before retrying\n  } else throw e;\n}","preventionTips":["Always set input.type via the InputType enum, not raw numbers.","Use SDK input factories rather than hand-building input objects.","Validate type membership before encoding externally sourced inputs."],"tags":["input","encode","transaction","typescript"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}