{"record":{"id":"b599868d374f8f67","repo":"spacedriveapp/spacedrive","slug":"cannot-set-key","errorCode":null,"errorMessage":"Cannot set key: {}","messagePattern":"Cannot set key: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"critical","filePath":"apps/cli/src/domains/config/mod.rs","lineNumber":74,"sourceCode":"\t\t\t\t\t.current_library_id\n\t\t\t\t\t.map(|id| id.to_string())\n\t\t\t\t\t.unwrap_or_else(|| \"(not set)\".to_string()),\n\t\t\t\t\"update.repo\" => config.update.repo.clone(),\n\t\t\t\t\"update.channel\" => config.update.channel.clone(),\n\t\t\t\t_ => return Err(anyhow::anyhow!(\"Unknown config key: {}\", key)),\n\t\t\t};\n\t\t\tprintln!(\"{}\", value);\n\t\t}\n\t\tConfigCmd::Set { key, value } => match key.as_str() {\n\t\t\t\"update.repo\" => {\n\t\t\t\tconfig.set_update_repo(value.clone(), &data_dir)?;\n\t\t\t\tprintln!(\"Set update.repo = {}\", value);\n\t\t\t}\n\t\t\t\"update.channel\" => {\n\t\t\t\tconfig.set_update_channel(value.clone(), &data_dir)?;\n\t\t\t\tprintln!(\"Set update.channel = {}\", value);\n\t\t\t}\n\t\t\t_ => return Err(anyhow::anyhow!(\"Cannot set key: {}\", key)),\n\t\t},\n\t}\n\n\tOk(())\n}\n","sourceCodeStart":56,"sourceCodeEnd":80,"githubUrl":"https://github.com/spacedriveapp/spacedrive/blob/6dfeccf2113039e35f2ce735f945e70dc3e4ea45/apps/cli/src/domains/config/mod.rs#L56-L80","documentation":"Wrapper error thrown when NetworkingService::start() fails during start_networking. Notably, the code casts an Arc pointer to *mut and calls start() through unsafe, justified by a comment that start() runs only once during initialization; the wrapped error is the underlying start failure, not the cast itself. If init (error 216) already failed, self.networking is None and start_networking silently does nothing — so reaching this error means creation succeeded but startup did not.","triggerScenarios":"Calling start_networking after successful creation, where the p2p endpoint fails to bind/discover — occupied ports, network interfaces unavailable at startup, firewall blocking the listen socket, or relay/discovery unreachable.","commonSituations":"Another daemon instance already bound the port; container with restrictive network config; system boot ordering where networking starts before interfaces are up; corporate firewall blocking discovery endpoints.","solutions":["Read the inner error after the colon for the failing bind/discovery step.","Ensure no second sd-daemon instance is running (check process list / socket files).","Verify the required ports/interfaces are available and firewall rules allow them.","Retry startup once the network interface is up (init succeeded, so only start() needs to re-run)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Only attempt start when creation succeeded and no other instance holds the port.\nif services.networking().is_none() {\n    return Err(anyhow::anyhow!(\"networking not initialized; run init first\"));\n}","typeGuard":null,"tryCatchPattern":"// Retry start a bounded number of times for boot-order races (interface not yet up).\nlet mut attempt = 0;\nloop {\n    match services.start_networking().await {\n        Ok(()) => break,\n        Err(e) if attempt < 3 => {\n            attempt += 1;\n            tokio::time::sleep(std::time::Duration::from_secs(2_u64.pow(attempt))).await;\n        }\n        Err(e) => return Err(e),\n    }\n}","preventionTips":["Ensure exactly one daemon instance runs per data dir (lockfile) to avoid port conflicts.","Order startup after network availability (systemd After=network-online.target).","Log the inner start() error; the unsafe-pointer wrapper makes silent failure extra costly."],"tags":["rust","networking","startup","p2p","unsafe"],"backgroundTag":null,"analyzedSha":"6dfeccf2113039e35f2ce735f945e70dc3e4ea45","analyzedAt":"2026-08-16T11:26:17.074Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}