{"record":{"id":"42b50e30214b7775","repo":"FuelLabs/sway","slug":"invalid-salt-format","errorCode":null,"errorMessage":"Invalid salt format: {}","messagePattern":"Invalid salt format: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"forc-pkg/src/manifest/dep_modifier.rs","lineNumber":323,"sourceCode":"            doc[&section_name] = Item::Table(Table::new());\n        }\n\n        let table = doc[section_name.as_str()].as_table_mut().unwrap();\n\n        match self {\n            Section::Deps => {\n                let item = match dep_data {\n                    Dependency::Simple(ver) => ver.to_string().into(),\n                    Dependency::Detailed(details) => {\n                        Item::Value(toml_edit::Value::InlineTable(generate_table(&details)))\n                    }\n                };\n                table.insert(&dep_name, item);\n            }\n            Section::ContractDeps => {\n                let resolved_salt = match salt.as_ref().or(salt.as_ref()) {\n                    Some(s) => {\n                        HexSalt::from_str(s).map_err(|e| anyhow!(\"Invalid salt format: {}\", e))?\n                    }\n                    None => HexSalt(fuel_tx::Salt::default()),\n                };\n                let contract_dep = ContractDependency {\n                    dependency: dep_data,\n                    salt: resolved_salt.clone(),\n                };\n\n                let dep = &contract_dep.dependency;\n                let salt: &HexSalt = &contract_dep.salt;\n                let item = match dep {\n                    Dependency::Simple(ver) => {\n                        let mut inline = InlineTable::default();\n                        inline.insert(\"version\", Value::from(ver.to_string()));\n                        inline.insert(\"salt\", Value::from(format!(\"0x{salt}\")));\n                        Item::Value(toml_edit::Value::InlineTable(inline))\n                    }\n                    Dependency::Detailed(details) => {","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/FuelLabs/sway/blob/47e5e902faa42baf652dd6a0c88cd23390c1a614/forc-pkg/src/manifest/dep_modifier.rs#L305-L341","documentation":"When forc add inserts a contract dependency into Forc.toml's [contract-dependencies], the optional salt is converted via HexSalt::from_str; failure is wrapped as 'Invalid salt format'. The underlying causes are exactly the two wrapped errors from manifest/mod.rs: a salt not starting with 0x, or a 0x-prefixed body that is not exactly 64 hex characters (32 bytes).","triggerScenarios":"forc add --contract-dependency dep --salt <value> (or the programmatic equivalent calling the DepModifier insert API) where value is not 0x followed by 64 hex characters.","commonSituations":"Passing an EVM-style salt with different length; copying a salt with whitespace/quotes from a terminal; forgetting the 0x prefix; using a short placeholder like 0x0.","solutions":["Format the salt as 0x + 64 hex chars, e.g. 0x0000000000000000000000000000000000000000000000000000000000000000 for the default.","Omit --salt entirely to get the default zero salt (HexSalt(fuel_tx::Salt::default()) in the source).","Strip surrounding quotes/whitespace the shell may have preserved in the value."],"exampleFix":"# before\n$ forc add --contract-dependency mydep --salt deadbeef\n\n# after\n$ forc add --contract-dependency mydep --salt 0x00000000000000000000000000000000deadbeef000000000000000000000000","handlingStrategy":"validation","validationCode":"// Rust, pre-check a --salt value before the DepModifier runs:\nfn valid_hex_salt(s: &str) -> bool {\n    let body = s.strip_prefix(\"0x\").unwrap_or(\"\");\n    body.len() == 64 && body.chars().all(|c| c.is_ascii_hexdigit())\n}","typeGuard":null,"tryCatchPattern":"// anyhow Result from the dep-modifier flow; catch and restate format:\nmatch add_contract_dep(...) {\n    Err(e) if e.to_string().contains(\"Invalid salt format\") =>\n        eprintln!(\"salt must be 0x + 64 hex chars, or omitted\"),\n    other => other.unwrap(),\n}","preventionTips":["Always format salts as 0x followed by 64 hex characters.","Omit --salt for the default zero salt.","Copy salts from Forc.lock output, which is already correctly formatted."],"tags":["forc","cli","salt","contract-dependency"],"backgroundTag":null,"analyzedSha":"47e5e902faa42baf652dd6a0c88cd23390c1a614","analyzedAt":"2026-08-16T07:57:45.555Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}