{"record":{"id":"2baab7236572dfb0","repo":"FuelLabs/fuels-ts","slug":"unsupported-encoding-version-2baab7","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/utils/json-abi.ts","lineNumber":23,"sourceCode":"import type { AbiFunction, JsonAbi } from '../types/JsonAbiNew';\n\nimport { ENCODING_V1, VOID_TYPE, type EncodingVersion } from './constants';\n\n/**\n * Asserts that the encoding version is supported by the ABI coder.\n *\n * @param encoding - the encoding version to check\n * @returns the encoding version\n * @throws FuelError if the encoding version is not supported\n */\nexport const getEncodingVersion = (encoding?: string): EncodingVersion => {\n  switch (encoding) {\n    case undefined:\n    case ENCODING_V1:\n      return ENCODING_V1;\n\n    default:\n      throw new FuelError(\n        ErrorCode.UNSUPPORTED_ENCODING_VERSION,\n        `Encoding version '${encoding}' is unsupported.`\n      );\n  }\n};\n\n/**\n * Find a function by name in the ABI.\n *\n * @param abi - the JsonAbi object\n * @param name - the name of the function to find\n * @returns the JsonAbi function object\n */\nexport const findFunctionByName = (abi: JsonAbi, name: string): AbiFunction => {\n  const fn = abi.functions.find((f) => f.name === name);\n  if (!fn) {\n    throw new FuelError(\n      ErrorCode.FUNCTION_NOT_FOUND,","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/abi-coder/src/utils/json-abi.ts#L5-L41","documentation":"getEncodingVersion normalizes an optional encoding string to a canonical EncodingVersion. Only undefined and ENCODING_V1 ('1') are accepted; every other value (including null, empty string, or a future version) is rejected. This is the input-validation counterpart to getCoderForEncoding's dispatch.","triggerScenarios":"Calling getEncodingVersion with a string other than '1' or undefined; reading an `encoding` field from user config / JSON and passing it through without narrowing; migrating from a config that used a different version identifier.","commonSituations":"Config files that stored encoding as a generic string; cross-version migrations; user input that supplies an empty or malformed version field.","solutions":["Treat the encoding field as optional and omit it when you want the default (V1).","Narrow config-supplied values to EncodingVersion before calling; reject unknown values at the config layer.","Use the ENCODING_V1 constant instead of a literal when pinning is required."],"exampleFix":"// before\nconst v = getEncodingVersion(config.encoding); // config.encoding may be '' or '0'\n\n// after\nimport { ENCODING_V1, getEncodingVersion } from '@fuel-ts/abi-coder';\nconst v = getEncodingVersion(\n  config.encoding === ENCODING_V1 ? config.encoding : undefined\n);","handlingStrategy":"type-guard","validationCode":"import { ENCODING_V1 } from '@fuel-ts/abi-coder';\nfunction asEncodingVersion(v: unknown) {\n  if (v !== undefined && v !== ENCODING_V1) throw new Error(`unsupported encoding: ${v}`);\n  return v as undefined | typeof ENCODING_V1;\n}","typeGuard":"import { ENCODING_V1, type EncodingVersion } from '@fuel-ts/abi-coder';\nfunction isEncodingVersion(v: unknown): v is EncodingVersion | undefined {\n  return v === undefined || v === ENCODING_V1;\n}","tryCatchPattern":null,"preventionTips":["Do not store encoding as a free-form string in config; narrow it at the boundary.","Default to undefined (V1) unless you have a reason to pin.","Reject unknown encoding values early, before they reach the SDK."],"tags":["abi-coder","encoding-version","config","validation"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}