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
Same codegen path as the enum case, but for struct types: when a struct is a logged type, abigen! parses the log id string from the ABI into u64 to emit the Log::LOG_ID_U64 constant (packages/fuels-code-gen/src/program_bindings/custom_types/structs.rs:76). The expect fires when the id string cannot be parsed as u64.
Source
Thrown at packages/fuels-code-gen/src/program_bindings/custom_types/structs.rs:76
struct_ident: &Ident,
components: &Components,
generics: &[Ident],
no_std: bool,
log_id: Option<&String>,
) -> TokenStream {
let derive_default = components
.is_empty()
.then(|| quote!(::core::default::Default,));
let maybe_disable_std = no_std.then(|| quote! {#[NoStd]});
let (generics_wo_bounds, generics_w_bounds) = tokenize_generics(generics);
let (field_names, field_types): (Vec<_>, Vec<_>) = unzip_field_names_and_types(components);
let (phantom_fields, phantom_types) =
components.generate_parameters_for_unused_generics(generics);
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 #struct_ident #generics_wo_bounds {
const LOG_ID: &'static str = #log_id;
const LOG_ID_U64: u64 = #log_id_u64;
}
}
});
quote! {
#[derive(
Clone,
Debug,
Eq,
PartialEq,
#derive_default
::fuels::macros::Parameterize,
::fuels::macros::Tokenizable,View on GitHub (pinned to d9a250a518)
Solutions
- Regenerate the ABI with forc build using the toolchain matched to your fuels crate
- Verify the loggedTypes ids are plain decimal strings parseable as u64
- Upgrade fuels to the version matching your ABI format
Example fix
// before
"loggedTypes": [{ "id": "log-1", ... }]
// after
"loggedTypes": [{ "id": "16423", ... }] 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
- Treat generated ABIs as build artifacts, never as editable files
- Keep the forc/fuels version pair in sync
- Validate the ABI in CI before compiling bindings
When it happens
Trigger: abigen! on an ABI where the loggedTypes id attached to a struct type is not a decimal u64 string (corruption, manual edit, or forc/SDK version mismatch).
Common situations: Hand-edited ABIs; ABI files copied between projects built with different forc versions; partial rewrites of the JSON.
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/080b9dce227f9481.
Report an issue: GitHub.