{"record":{"id":"4eb21f28b7ab9bfa","repo":"FuelLabs/fuels-ts","slug":"unsupported-encoding-version","errorCode":"UNSUPPORTED_ENCODING_VERSION","errorMessage":"Encoding version ${encoding} is unsupported.","messagePattern":"Encoding version (.+?) is unsupported\\.","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/abi-coder/src/encoding/strategies/getCoderForEncoding.ts","lineNumber":21,"sourceCode":"import type { GetCoderFn } from '../../types/GetCoder';\nimport type { EncodingVersion } from '../../utils/constants';\nimport { ENCODING_V1 } from '../../utils/constants';\n\nimport { getCoder as getCoderV1 } from './getCoderV1';\n\n/**\n * Retrieves the appropriate encoding function for a given encoding version.\n *\n * @param encoding - the version to provide a strategy for.\n * @throws for an unsupported encoding version.\n * @returns the appropriate encoding strategy.\n */\nexport function getCoderForEncoding(encoding: EncodingVersion = ENCODING_V1): GetCoderFn {\n  switch (encoding) {\n    case ENCODING_V1:\n      return getCoderV1;\n    default:\n      throw new FuelError(\n        ErrorCode.UNSUPPORTED_ENCODING_VERSION,\n        `Encoding version ${encoding} is unsupported.`\n      );\n  }\n}\n","sourceCodeStart":3,"sourceCodeEnd":27,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/abi-coder/src/encoding/strategies/getCoderForEncoding.ts#L3-L27","documentation":"getCoderForEncoding dispatches an encoding strategy by version. The EncodingVersion type is the literal '1' (ENCODING_V1); the switch handles only ENCODING_V1 and falls through to default for any other value. Passing any other string (e.g. '0', '2', 'v1') is therefore rejected at strategy resolution time.","triggerScenarios":"Calling getCoderForEncoding with an explicit encoding argument that is not '1' or undefined; passing a value read from a config field typed as string instead of EncodingVersion; building a coder via options.encoding with an unsupported version.","commonSituations":"Upgrading the SDK and assuming an older or newer encoding version string still works; copy-pasting encoding identifiers from docs of a different major version; storing encoding in JSON config without narrowing the type.","solutions":["Omit the encoding option (defaults to ENCODING_V1) unless you specifically need to pin it.","If pinning, pass the imported ENCODING_V1 constant rather than a string literal.","Narrow any externalized encoding value to EncodingVersion before passing it in."],"exampleFix":"// before\nconst coder = getCoderForEncoding('v1');\n\n// after\nimport { ENCODING_V1 } from '@fuel-ts/abi-coder';\nconst coder = getCoderForEncoding(ENCODING_V1);","handlingStrategy":"type-guard","validationCode":"import { ENCODING_V1, type EncodingVersion } from '@fuel-ts/abi-coder';\nfunction isValidEncoding(v: unknown): v is EncodingVersion {\n  return v === undefined || v === ENCODING_V1;\n}\nif (!isValidEncoding(maybeEncoding)) throw new Error('unsupported encoding');","typeGuard":"import { ENCODING_V1, type EncodingVersion } from '@fuel-ts/abi-coder';\nfunction isEncodingVersion(v: unknown): v is EncodingVersion {\n  return v === undefined || v === ENCODING_V1;\n}","tryCatchPattern":null,"preventionTips":["Omit the encoding option unless you must pin it.","Pass the ENCODING_V1 constant, never a string literal.","Narrow config-supplied encoding values at the config layer, not at the call site."],"tags":["abi-coder","encoding-version","strategy","config"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}