{"record":{"id":"225dc37d20f946c2","repo":"FuelLabs/fuels-ts","slug":"invalid-transaction-output","errorCode":"INVALID_TRANSACTION_OUTPUT","errorMessage":"Invalid transaction output type: ${type}.","messagePattern":"Invalid transaction output type: (.+?)\\.","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/transactions/src/coders/output.ts","lineNumber":293,"sourceCode":"      }\n      case OutputType.Contract: {\n        parts.push(new OutputContractCoder().encode(value));\n        break;\n      }\n      case OutputType.Change: {\n        parts.push(new OutputChangeCoder().encode(value));\n        break;\n      }\n      case OutputType.Variable: {\n        parts.push(new OutputVariableCoder().encode(value));\n        break;\n      }\n      case OutputType.ContractCreated: {\n        parts.push(new OutputContractCreatedCoder().encode(value));\n        break;\n      }\n      default: {\n        throw new FuelError(\n          ErrorCode.INVALID_TRANSACTION_OUTPUT,\n          `Invalid transaction output type: ${type}.`\n        );\n      }\n    }\n\n    return concat(parts);\n  }\n\n  decode(data: Uint8Array, offset: number): [Output, 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 OutputType;\n    switch (type) {\n      case OutputType.Coin: {\n        [decoded, o] = new OutputCoinCoder().decode(data, o);","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/transactions/src/coders/output.ts#L275-L311","documentation":"Thrown by OutputCoder.encode() when output.type is not one of OutputType (Coin=0, Contract=1, Change=2, Variable=3, ContractCreated=4). The encode switch falls through to default. It indicates an output object with an out-of-range type.","triggerScenarios":"Manually constructing an Output with an invalid type number; assigning type: 5+; building transaction outputs from unvalidated external data.","commonSituations":"Hand-assembling outputs instead of using SDK helpers; protocol/SDK version mismatch introducing a new output kind; off-by-one type assignments.","solutions":["Use the OutputType enum and SDK output factories when constructing outputs.","Validate output.type is one of the five known OutputType values before encoding.","Upgrade @fuel-ts/transactions if a newer output type is required."],"exampleFix":"// before\nconst out = { type: 7, ... };\n\n// after\nimport { OutputType } from '@fuel-ts/transactions';\nconst out = { type: OutputType.Coin, ... };","handlingStrategy":"type-guard","validationCode":"import { OutputType } from '@fuel-ts/transactions';\n\nconst VALID_OUTPUT_TYPES = new Set([OutputType.Coin, OutputType.Contract, OutputType.Change, OutputType.Variable, OutputType.ContractCreated]);\noutputs.forEach(o => { if (!VALID_OUTPUT_TYPES.has(o.type as OutputType)) throw new Error(`Bad output type ${o.type}`); });","typeGuard":"import { OutputType } from '@fuel-ts/transactions';\nfunction isValidOutput(o: { type: number }): boolean {\n  return [OutputType.Coin, OutputType.Contract, OutputType.Change, OutputType.Variable, OutputType.ContractCreated].includes(o.type as OutputType);\n}","tryCatchPattern":"try {\n  outputCoder.encode(value);\n} catch (e) {\n  if (e instanceof FuelError && e.code === ErrorCode.INVALID_TRANSACTION_OUTPUT) {\n    // coerce output.type to a valid OutputType enum member before retrying\n  } else throw e;\n}","preventionTips":["Set output.type via the OutputType enum, not raw numbers.","Prefer SDK output helpers over manual construction.","Validate type membership before encoding externally sourced outputs."],"tags":["output","encode","transaction","typescript"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}