{"record":{"id":"a6dc4df88e05cf55","repo":"FuelLabs/fuels-rs","slug":"failed-to-resolve-log-type","errorCode":null,"errorMessage":"Failed to resolve log type","messagePattern":"Failed to resolve log type","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/fuels-code-gen/src/program_bindings/abigen/logs.rs","lineNumber":29,"sourceCode":"    let resolved_logs = resolve_logs(logged_types);\n    let log_id_log_formatter_pairs = generate_log_id_log_formatter_pairs(&resolved_logs);\n    quote! {::fuels::core::codec::log_formatters_lookup(vec![#(#log_id_log_formatter_pairs),*], #contract_id)}\n}\n\n#[derive(Debug)]\nstruct ResolvedLog {\n    log_id: String,\n    log_formatter: TokenStream,\n}\n\n/// Reads the parsed logged types from the ABI and creates ResolvedLogs\nfn resolve_logs(logged_types: &[FullLoggedType]) -> Vec<ResolvedLog> {\n    logged_types\n        .iter()\n        .map(|l| {\n            let resolved_type = TypeResolver::default()\n                .resolve(&l.application)\n                .expect(\"Failed to resolve log type\");\n\n            let is_error_type = l\n                .application\n                .type_decl\n                .components\n                .iter()\n                .any(|component| component.error_message.is_some());\n\n            let log_formatter = if is_error_type {\n                quote! {\n                    ::fuels::core::codec::LogFormatter::new_error::<#resolved_type>()\n                }\n            } else {\n                quote! {\n                    ::fuels::core::codec::LogFormatter::new_log::<#resolved_type>()\n                }\n            };\n","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/FuelLabs/fuels-rs/blob/d9a250a51818dda64bfeb5ef7cc19cf27bdcd623/packages/fuels-code-gen/src/program_bindings/abigen/logs.rs#L11-L47","documentation":"During abigen! code generation the SDK iterates the ABI's loggedTypes and resolves each type application with TypeResolver to build the Rust log-decoder bindings. This expect fires when a logged type in the ABI JSON cannot be resolved to a Rust type, meaning the type declaration graph (typeDecl plus its components) contains a shape the resolver does not understand or a reference it cannot follow.","triggerScenarios":"Running abigen! with an ABI generated by a forc/Sway version newer than the SDK supports (new type constructs), a hand-edited or corrupted ABI JSON, or a logged type whose application references a typeId missing from the ABI's types array.","commonSituations":"Upgrading forc without upgrading fuels; copying an ABI from a project built with a different toolchain; manually editing or truncating the ABI JSON.","solutions":["Regenerate the ABI (forc build) with the forc version pinned by the fuels release you use","Upgrade the fuels crate to the version paired with your forc/Sway version (SDK version table)","Validate the ABI JSON parses and that every typeId referenced by loggedTypes exists in the types array","If the logged type is exotic, simplify it in the Sway contract (replace complex generics/nested enums) and rebuild"],"exampleFix":"# before: ABI produced by whatever forc is on PATH\nforc build\n\n# after: pin the forc version paired with your fuels crate, then rebuild\nfuelup use <forc matching your fuels release>\nforc build --release\n# re-run cargo build so abigen! resolves every logged type","handlingStrategy":"validation","validationCode":"# (shell) validate the ABI before compiling the crate that runs abigen!\njq empty out/release/contract-abi.json || echo 'invalid ABI JSON'\n# every loggedType must reference a declared type:\njq -e '[.loggedTypes[]?.application.typeDecl.typeId] - [.types[].typeId] | length == 0' out/release/contract-abi.json","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always regenerate the ABI with the forc version pinned by your fuels release (fuelup default pin)","Never hand-edit generated ABI JSON","Commit the contract source next to its generated ABI so CI can rebuild both together","Upgrade fuels and forc in the same change set"],"tags":["codegen","abigen","abi","compile-time","logging"],"backgroundTag":null,"analyzedSha":"d9a250a51818dda64bfeb5ef7cc19cf27bdcd623","analyzedAt":"2026-08-16T09:49:30.618Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}