FuelLabs/fuels-ts · error · FuelError

INVALID_COMPONENT

INVALID_COMPONENT

Error message

The provided ABI type is too long: ${jsonABIType.type}.

What it means

Thrown by the `ResolvedAbiType` constructor (code `INVALID_COMPONENT`) when a type string in the ABI exceeds 256 characters. This is a sanity guard against pathological/malformed ABI type strings, since a real Sway type longer than 256 chars almost always indicates corruption or a bad hand-edited ABI.

Source

Thrown at packages/abi-coder/src/ResolvedAbiType.ts:22

import { arrayRegEx, enumRegEx, genericRegEx, stringRegEx, structRegEx } from './utils/constants';
import { findTypeById } from './utils/json-abi';

export class ResolvedAbiType {
  readonly abi: JsonAbiOld;
  name: string;
  readonly type: string;
  readonly originalTypeArguments: readonly JsonAbiArgument[] | null;
  readonly components: readonly ResolvedAbiType[] | null;

  constructor(abi: JsonAbiOld, argument: JsonAbiArgument) {
    this.abi = abi;

    this.name = argument.name;

    const jsonABIType = findTypeById(abi, argument.type);

    if (jsonABIType.type.length > 256) {
      throw new FuelError(
        ErrorCode.INVALID_COMPONENT,
        `The provided ABI type is too long: ${jsonABIType.type}.`
      );
    }

    this.type = jsonABIType.type;
    this.originalTypeArguments = argument.typeArguments;
    this.components = ResolvedAbiType.getResolvedGenericComponents(
      abi,
      argument,
      jsonABIType.components,
      jsonABIType.typeParameters ??
        ResolvedAbiType.getImplicitGenericTypeParameters(abi, jsonABIType.components)
    );
  }

  private static getResolvedGenericComponents(
    abi: JsonAbiOld,

View on GitHub (pinned to b3f37c91ac)

Solutions

  1. Regenerate the ABI by recompiling the Sway contract (`forc build`) — never hand-edit ABI type strings.
  2. Inspect the offending type in the ABI JSON (the message prints it) and locate the corruption.
  3. Ensure the file you pass as the ABI is the actual Sway-compiled JSON ABI, not a template or fragment.

Example fix

// before: hand-edited abi.json with a corrupted type
{ "type": "u64u64u64....(300 chars)...." }
// after: regenerate with forc and load the clean ABI
$ forc build
const abi = loadAbi('./out/project-abi.json');
Defensive patterns

Strategy: validation

Validate before calling

// reject pathological ABIs before constructing coders
const MAX_TYPE_LEN = 256;
const offenders = abi.types.filter((t) => t.type.length > MAX_TYPE_LEN);
if (offenders.length) {
  throw new Error(`ABI has ${offenders.length} type(s) longer than ${MAX_TYPE_LEN} chars`);
}

Try / catch

try {
  const resolved = new ResolvedAbiType(abi, arg);
} catch (e) {
  if (e.code === 'INVALID_COMPONENT' && /too long/.test(e.message)) {
    // ABI is corrupted — regenerate via `forc build`
  }
  throw e;
}

Prevention

When it happens

Trigger: Loading a hand-crafted or corrupted ABI where a type's `type` field is a giant string; a codegen bug producing runaway recursive type strings; binary corruption of the JSON ABI file.

Common situations: Manually editing a JSON ABI and accidentally duplicating/pasting content into a type field; feeding a non-Sway ABI to the coder; truncation/encoding artifacts producing a long garbage string.

Related errors


AI-assisted analysis of FuelLabs/fuels-ts@b3f37c91ac (2026-08-12). Data as JSON: /api/errors/4b57a6925920738f. Report an issue: GitHub.