FuelLabs/fuels-ts · error · FuelError

INVALID_COMPONENT

INVALID_COMPONENT

Error message

The provided Array type is missing an item of 'component'.

What it means

Inside getCoderV1, an ABI type whose `type` field matches the array regex must supply at least one component (the element type). When components[0] is undefined the function cannot construct an ArrayCoder and throws INVALID_COMPONENT. This catches malformed array declarations in the JSON ABI before they reach the element coder.

Source

Thrown at packages/abi-coder/src/encoding/strategies/getCoderV1.ts:112

  const stringMatch = stringRegEx.exec(resolvedAbiType.type)?.groups;
  if (stringMatch) {
    const length = parseInt(stringMatch.length, 10);

    return new StringCoder(length);
  }

  // ABI types underneath MUST have components by definition

  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
  const components = resolvedAbiType.components!;

  const arrayMatch = arrayRegEx.exec(resolvedAbiType.type)?.groups;

  if (arrayMatch) {
    const length = parseInt(arrayMatch.length, 10);
    const arg = components[0];
    if (!arg) {
      throw new FuelError(
        ErrorCode.INVALID_COMPONENT,
        `The provided Array type is missing an item of 'component'.`
      );
    }

    const arrayElementCoder = getCoder(arg);
    return new ArrayCoder(arrayElementCoder as Coder, length);
  }

  if (resolvedAbiType.type === VEC_CODER_TYPE) {
    const arg = findVectorBufferArgument(components);
    const argType = new ResolvedAbiType(resolvedAbiType.abi, arg);

    const itemCoder = getCoder(argType, { encoding: ENCODING_V1 });
    return new VecCoder(itemCoder as Coder);
  }

  // component name

View on GitHub (pinned to b3f37c91ac)

Solutions

  1. Open the ABI JSON and confirm every array-typed entry has a non-empty components array with a valid element type.
  2. Regenerate the ABI from the Sway source with `forc build` rather than editing by hand.
  3. Validate the ABI against the expected schema before passing it to the coder/Interface.

Example fix

// before (broken ABI fragment)
{ "type": "[u64; 3]", "components": [], "typeId": 5 }

// after
{ "type": "[u64; 3]", "components": [ { "name": "__array_element", "type": "u64", "typeArguments": [] } ], "typeId": 5 }
Defensive patterns

Strategy: validation

Validate before calling

function validateArrayComponents(abi: JsonAbi) {
  for (const t of abi.types) {
    if (/\[/.test(t.type) && (!t.components || t.components.length === 0)) {
      throw new Error(`array type ${t.typeId} (${t.type}) missing components`);
    }
  }
}

Try / catch

try { getCoder(resolvedAbiType); } catch (e) {
  if (e instanceof FuelError && e.code === ErrorCode.INVALID_COMPONENT) { /* report bad ABI */ }
  throw e;
}

Prevention

When it happens

Trigger: Loading a hand-edited or generated JSON ABI where an array-typed entry (e.g. type matching `[...;N]`) has an empty or missing `components` array; ABI produced by a buggy/old compiler; ABI file truncated during serialization.

Common situations: Editing an ABI JSON to add an array type but forgetting the components field; merging ABI fragments incorrectly; Sway compiler version that emits a different components shape than expected.

Related errors


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