{"record":{"id":"c420db4f6be0e773","repo":"ruvnet/RuView","slug":"hap-device-id-is-required-when-hap-is-enabled","errorCode":null,"errorMessage":"--hap-device-id is required when HAP is enabled","messagePattern":"--hap-device-id is required when HAP is enabled","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"v2/crates/homecore-server/src/hap.rs","lineNumber":76,"sourceCode":"        let _ = (hc, bind_addr);\n        anyhow::bail!(\n            \"HAP was requested but this binary was built without the `hap-server` feature\"\n        );\n    }\n\n    #[cfg(feature = \"hap-server\")]\n    {\n        use std::sync::Arc;\n\n        use homecore_hap::{\n            start_server, HapBridge, HapServerConfig, HapServiceRecord, MdnsSdAdvertiser,\n            PairingStore,\n        };\n\n        let device_id = config\n            .device_id\n            .as_deref()\n            .ok_or_else(|| anyhow::anyhow!(\"--hap-device-id is required when HAP is enabled\"))?;\n        let advertise_addr = config.advertise_addr.ok_or_else(|| {\n            anyhow::anyhow!(\"--hap-advertise-addr is required when HAP is enabled\")\n        })?;\n        if let Some(parent) = config.pairing_store.parent() {\n            std::fs::create_dir_all(parent)?;\n        }\n\n        let advertiser = Arc::new(MdnsSdAdvertiser::new(\n            config.hostname.clone(),\n            advertise_addr,\n        )?);\n        let pairings = if config.pairing_store.exists() {\n            if config.setup_code.is_some() {\n                tracing::warn!(\n                    \"ignoring --hap-setup-code because the pairing store already exists\"\n                );\n            }\n            PairingStore::open(&config.pairing_store)?","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/v2/crates/homecore-server/src/hap.rs#L58-L94","documentation":"Anyhow error at HAP startup: HAP is enabled and compiled in, but config.device_id is None because --hap-device-id was not supplied. The device_id is load-bearing downstream -- it is persisted into the PairingStore at creation and embedded in the HAP service record (HapServiceRecord::bridge(..., device_id)) that HomeKit clients use to identify the bridge, so startup refuses to invent one.","triggerScenarios":"Enabling HAP flags but omitting --hap-device-id; passing an empty string for the flag (Option stays effectively unusable for the record); config files copied from examples without filling in the ID.","commonSituations":"First-time HAP setup following a guide that skips the ID argument; scripts templated per-host where one host is missing the variable; containerized deployments losing the argument in env-to-flag translation.","solutions":["Pass a stable unique --hap-device-id (e.g. a generated UUID v4) when enabling HAP","Persist the same ID across restarts (config file or provisioning script) -- changing it later invalidates existing pairings because the bridge identity changes","Generate one with uuidgen and store it alongside the pairing store path in your deployment config"],"exampleFix":"# before\n./homecore-server --hap-enable --hap-advertise-addr 192.168.1.10\n# error: --hap-device-id is required when HAP is enabled\n\n# after\n./homecore-server --hap-enable --hap-advertise-addr 192.168.1.10 \\\n  --hap-device-id 6f1d2b34-9c8e-4a5d-b0f1-7e2c3d4a5b6c","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\n: \"${HAP_DEVICE_ID:?HAP_DEVICE_ID must be set (uuidgen)}\"\nexec homecore-server --hap-enable --hap-device-id \"$HAP_DEVICE_ID\" \"$@\"","typeGuard":"fn hap_config_valid(cfg: &HapConfig) -> bool {\n    cfg.enabled && cfg.device_id.as_deref().is_some_and(|id| !id.trim().is_empty())\n}","tryCatchPattern":null,"preventionTips":["Generate the device ID once (uuidgen) and store it in the host's persistent config","Never change --hap-device-id after pairing; iOS clients pair against that identity","Fail the deployment script early if HAP is enabled but the ID variable is empty"],"tags":["rust","cli","hap","homekit","configuration","device-id"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}