{"record":{"id":"aedc57fe38c93110","repo":"FuelLabs/fuels-ts","slug":"not-implemented","errorCode":"NOT_IMPLEMENTED","errorMessage":"Invalid upgrade purpose","messagePattern":"Invalid upgrade purpose","errorType":"validation","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/account/src/providers/transaction-request/upgrade-transaction-request.ts","lineNumber":152,"sourceCode":"    let upgradePurpose: UpgradePurpose;\n\n    if (this.upgradePurpose.type === UpgradePurposeTypeEnum.ConsensusParameters) {\n      upgradePurpose = {\n        type: UpgradePurposeTypeEnum.ConsensusParameters,\n        data: {\n          witnessIndex: this.bytecodeWitnessIndex,\n          checksum: this.upgradePurpose.checksum,\n        },\n      };\n    } else if (this.upgradePurpose.type === UpgradePurposeTypeEnum.StateTransition) {\n      upgradePurpose = {\n        type: UpgradePurposeTypeEnum.StateTransition,\n        data: {\n          bytecodeRoot: hexlify(this.upgradePurpose.data),\n        },\n      };\n    } else {\n      throw new FuelError(FuelError.CODES.NOT_IMPLEMENTED, 'Invalid upgrade purpose');\n    }\n\n    return {\n      type: TransactionType.Upgrade,\n      ...super.getBaseTransaction(),\n      upgradePurpose,\n    };\n  }\n\n  /**\n   * Gets the Transaction ID by hashing the transaction\n   *\n   * @param chainId - The chain ID.\n   *\n   * @returns - A hash of the transaction, which is the transaction ID.\n   */\n  getTransactionId(chainId: number): string {\n    return hashTransaction(this, chainId);","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/account/src/providers/transaction-request/upgrade-transaction-request.ts#L134-L170","documentation":"Thrown by `UpgradeTransactionRequest.toTransaction()` when `upgradePurpose.type` is neither `ConsensusParameters` nor `StateTransition`. The method assembles the on-chain `TransactionUpgrade` structure and reaches the else branch only for an unrecognized purpose discriminator. Coded as `NOT_IMPLEMENTED` because a new/unknown purpose type is not yet handled.","triggerScenarios":"Constructing an `UpgradeTransactionRequest` with an `upgradePurpose` object whose `type` field is missing, undefined, or a value outside `UpgradePurposeTypeEnum`. Calling `.getTransactionId()` or sending the tx (which invokes `toTransaction()`).","commonSituations":"Building an upgrade transaction from a config object where `upgradePurpose` was not set; version mismatch where the enum gained a new purpose type not handled by your SDK build; serializing/deserializing an upgrade request that lost the type field.","solutions":["Set `upgradePurpose.type` to either `UpgradePurposeTypeEnum.ConsensusParameters` (with `checksum`) or `UpgradePurposeTypeEnum.StateTransition` (with `data` bytecodeRoot).","Use the `UpgradeTransactionRequest` constructor or factory helpers that accept a strongly-typed `UpgradePurposeLike`, not a plain untyped object.","Upgrade @fuel-ts packages together so the enum definition is consistent."],"exampleFix":"// before\nconst req = new UpgradeTransactionRequest({ upgradePurpose: { checksum: '0x...' } });\n// after\nimport { UpgradePurposeTypeEnum } from '@fuel-ts/transactions';\nconst req = new UpgradeTransactionRequest({\n  upgradePurpose: {\n    type: UpgradePurposeTypeEnum.ConsensusParameters,\n    checksum: '0x...',\n  },\n});","handlingStrategy":"type-guard","validationCode":"import { UpgradePurposeTypeEnum } from '@fuel-ts/transactions';\nfunction isValidUpgradePurpose(p: any): boolean {\n  return p && (p.type === UpgradePurposeTypeEnum.ConsensusParameters || p.type === UpgradePurposeTypeEnum.StateTransition);\n}\nif (!isValidUpgradePurpose(config.upgradePurpose)) throw new Error('invalid upgrade purpose type');","typeGuard":"function isUpgradePurpose(v: unknown): v is import('@fuel-ts/transactions').UpgradePurpose {\n  const t = (v as any)?.type;\n  return t === UpgradePurposeTypeEnum.ConsensusParameters || t === UpgradePurposeTypeEnum.StateTransition;\n}","tryCatchPattern":"null","preventionTips":["Always set upgradePurpose.type from the enum, not a magic number.","Validate purpose immediately after constructing UpgradeTransactionRequest.","Keep SDK versions aligned so the enum is current."],"tags":["transaction","upgrade","purpose-validation","typescript"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}