FuelLabs/fuels-rs · error
log id should be a valid u64 string
Error message
log id should be a valid u64 string
What it means
In abigen! codegen, when an enum is also a logged type, the SDK takes the log id string from the ABI's loggedTypes entry and parses it into u64 to emit the Log::LOG_ID_U64 constant (enums path, packages/fuels-code-gen/src/program_bindings/custom_types/enums.rs:86). The expect fires when that id string is not a valid decimal u64.
Source
Thrown at packages/fuels-code-gen/src/program_bindings/custom_types/enums.rs:86
fn enum_decl(
enum_ident: &Ident,
components: &Components,
generics: &[Ident],
no_std: bool,
log_id: Option<&String>,
) -> TokenStream {
let maybe_disable_std = no_std.then(|| quote! {#[NoStd]});
let enum_variants = components.as_enum_variants();
let unused_generics_variant = components.generate_variant_for_unused_generics(generics);
let (generics_wo_bounds, generics_w_bounds) = tokenize_generics(generics);
let maybe_impl_error = maybe_impl_error(enum_ident, components);
let log_impl = log_id.map(|log_id| {
let log_id_u64: u64 = log_id
.parse::<u64>()
.expect("log id should be a valid u64 string");
quote! {
impl #generics_w_bounds ::fuels::core::codec::Log for #enum_ident #generics_wo_bounds {
const LOG_ID: &'static str = #log_id;
const LOG_ID_U64: u64 = #log_id_u64;
}
}
});
quote! {
#[allow(clippy::enum_variant_names)]
#[derive(
Clone,
Debug,
Eq,
PartialEq,
::fuels::macros::Parameterize,
::fuels::macros::Tokenizable,View on GitHub (pinned to d9a250a518)
Solutions
- Regenerate the ABI with forc build using the toolchain version matched to your fuels crate
- Inspect the loggedTypes ids in the JSON and make sure they are plain decimal number strings (e.g. "12345")
- Upgrade fuels to the version that supports your ABI format
Example fix
// before: hand-edited ABI with a mangled log id
"loggedTypes": [{ "id": "0x2a", ... }]
// after: plain decimal u64 string, regenerated by forc
"loggedTypes": [{ "id": "42", ... }] Defensive patterns
Strategy: validation
Validate before calling
# (shell) every loggedTypes id must round-trip through a u64 jq -e '[.loggedTypes[]?.id] | map(. == (.|tonumber|tostring)) | all' out/release/contract-abi.json
Type guard
fn valid_log_id(id: &str) -> bool {
id.parse::<u64>().is_ok()
} Prevention
- Regenerate ABIs with forc instead of editing them
- Pin forc and fuels to a matched version pair
- Add a CI lint that validates loggedTypes ids before cargo build
When it happens
Trigger: abigen! on an ABI where the loggedTypes id for an enum type is not a plain decimal u64 string: corrupted JSON, a hand-edited id, or an ABI format written by an incompatible forc version.
Common situations: Editing the ABI by hand; mixing ABI files produced by different forc versions; tooling that rewrites or reformats ids.
Related errors
- Failed to resolve log type
- log id should be a valid u64 string
- Only one `Abigen` command allowed
- Add an `Abigen(..)` command!
- is there
AI-assisted analysis of FuelLabs/fuels-rs@d9a250a518 (2026-08-16).
Data as JSON: /api/errors/894fc6498fbdabd6.
Report an issue: GitHub.