{"record":{"id":"2d475d322f75d7aa","repo":"FuelLabs/fuels-ts","slug":"json-abi-error","errorCode":"JSON_ABI_ERROR","errorMessage":"Couldn't extract struct name with: '${regex}'.\\n\\nCheck your JSON ABI.\\n\\n[source]\\n${JSON.stringify(rawAbiType, null, 2)}","messagePattern":"Couldn't extract struct name with: '(.+?)'\\.\\\\n\\\\nCheck your JSON ABI\\.\\\\n\\\\n\\[source\\]\\\\n(.+?)","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/abi-typegen/src/utils/extractStructName.ts","lineNumber":16,"sourceCode":"import { ErrorCode, FuelError } from '@fuel-ts/errors';\n\nimport type { JsonAbiType } from '../types/interfaces/JsonAbi';\n\nexport function extractStructName(params: { rawAbiType: JsonAbiType; regex: RegExp }) {\n  const { rawAbiType, regex } = params;\n\n  const matches = rawAbiType.type.match(regex);\n  const match = matches?.[2] ?? matches?.[1];\n\n  if (!match) {\n    let errorMessage = `Couldn't extract struct name with: '${regex}'.\\n\\n`;\n    errorMessage += `Check your JSON ABI.\\n\\n[source]\\n`;\n    errorMessage += `${JSON.stringify(rawAbiType, null, 2)}`;\n\n    throw new FuelError(ErrorCode.JSON_ABI_ERROR, errorMessage);\n  }\n\n  return match;\n}\n","sourceCodeStart":1,"sourceCodeEnd":21,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/abi-typegen/src/utils/extractStructName.ts#L1-L21","documentation":"extractStructName runs a regex against rawAbiType.type to pull the struct name out of the type string. If neither capture group 2 nor group 1 yields a value, the type string does not match the expected struct-naming shape and the typegen cannot produce a class name for the struct.","triggerScenarios":"An ABI struct-type entry whose `type` field does not match the supplied struct-name regex (malformed struct declaration); tooling emits a struct type string in an unexpected format; manual ABI edit broke the type field.","commonSituations":"ABI generated by an unsupported/old Sway version; hand-edited struct type strings; ABI converted between formats losing the struct name token.","solutions":["Inspect the offending rawAbiType printed in the error to see its `type` field.","Regenerate the ABI from current Sway source with the compiler version the SDK targets.","Correct the malformed `type` string so the struct name regex matches."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function assertStructNameExtractable(rawAbiType: JsonAbiType, regex: RegExp) {\n  const m = rawAbiType.type.match(regex);\n  if (!m && !m?.[1] && !m?.[2]) {\n    throw new Error(`cannot extract struct name from type: ${rawAbiType.type}`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Regenerate ABIs with the Sway compiler version targeted by the SDK.","Do not hand-edit struct `type` strings in the ABI.","Inspect the printed rawAbiType to spot the malformed type field."],"tags":["typegen","json-abi-error","struct","regex","abi-validation"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}