FuelLabs/fuels-ts · error · FuelError
PARSE_FAILED
PARSE_FAILED
Error message
Could not parse name from ABI file: ${filepath}. What it means
Abi constructor derives the contract/script/predicate class name from the ABI filepath using the regex /([^/]+)-abi\.json$/m. The captured group becomes the capitalized name. If the filepath does not end in `-abi.json` (with that exact suffix) the regex yields no match and the type generator cannot name the output.
Source
Thrown at packages/abi-typegen/src/abi/Abi.ts:63
storageSlotsContents?: string;
outputDir: string;
}) {
const {
filepath,
outputDir,
rawContents,
hexlifiedBinContents,
programType,
storageSlotsContents,
} = params;
const abiNameRegex = /([^/]+)-abi\.json$/m;
const abiName = filepath.match(abiNameRegex);
const couldNotParseName = !abiName || abiName.length === 0;
if (couldNotParseName) {
throw new FuelError(
ErrorCode.PARSE_FAILED,
`Could not parse name from ABI file: ${filepath}.`
);
}
this.programType = programType;
this.capitalizedName = `${normalizeString(abiName[1])}`;
this.camelizedName = this.capitalizedName.replace(/^./m, (x) => x.toLowerCase());
this.filepath = filepath;
this.rawContents = rawContents;
this.hexlifiedBinContents = hexlifiedBinContents;
this.storageSlotsContents = storageSlotsContents;
this.outputDir = outputDir;
const { types, functions, configurables, errorCodes } = this.parse();
this.types = types;View on GitHub (pinned to b3f37c91ac)
Solutions
- Rename the ABI file to follow the `<PascalName>-abi.json` convention (e.g. `MyContract-abi.json`).
- If files are user-supplied, normalize/rename them before invoking AbiTypeGen.
- Confirm the filepath passed to Abi is the full path ending in `-abi.json`.
Example fix
# before fuels typegen -i ./abis/MyContract.json ... # after fuels typegen -i ./abis/MyContract-abi.json ...
Defensive patterns
Strategy: validation
Validate before calling
function assertAbiFilename(filepath: string) {
if (!/[^/]+-abi\.json$/m.test(filepath)) {
throw new Error(`ABI file must end in '-abi.json': ${filepath}`);
}
} Type guard
function isAbiFilename(filepath: string): boolean {
return /[^/]+-abi\.json$/m.test(filepath);
} Prevention
- Adopt the `<Name>-abi.json` naming convention across the project.
- Validate filenames before invoking AbiTypeGen.
- Keep ABI/BIN filename stems aligned.
When it happens
Trigger: Passing an ABI filepath whose basename is not of the form `<Name>-abi.json` (e.g. `myabi.json`, `Foo.json`, `Foo-abi.ts`); passing a path with no basename match.
Common situations: Renaming ABI files away from the `-abi.json` convention; pointing typegen at downloaded ABIs that lost the suffix; cross-platform path separators altering the basename.
Related errors
- INVALID_INPUT_PARAMETERS
- MISSING_REQUIRED_PARAMETER
- NO_ABIS_FOUND
- ABI_MAIN_METHOD_MISSING
- ABI_MAIN_METHOD_MISSING
AI-assisted analysis of FuelLabs/fuels-ts@b3f37c91ac (2026-08-12).
Data as JSON: /api/errors/0eb2df9a206afeee.
Report an issue: GitHub.