{"record":{"id":"450892d9a2d3be09","repo":"zeroclaw-labs/zeroclaw","slug":"matrix-configure-either-access-token-or-passwo","errorCode":null,"errorMessage":"matrix: configure either `access_token` or `password`","messagePattern":"matrix: configure either `access_token` or `password`","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-channels/src/matrix.rs","lineNumber":3998,"sourceCode":"    pub fn new(\n        config: MatrixConfig,\n        alias: impl Into<String>,\n        peer_resolver: Arc<dyn Fn() -> Vec<String> + Send + Sync>,\n        state_dir: PathBuf,\n    ) -> Result<Self> {\n        if config.homeserver.trim().is_empty() {\n            bail!(\"matrix: `homeserver` is required\");\n        }\n        let has_token = config\n            .access_token\n            .as_deref()\n            .is_some_and(|t| !t.trim().is_empty());\n        let has_password = config\n            .password\n            .as_deref()\n            .is_some_and(|p| !p.trim().is_empty());\n        if !has_token && !has_password {\n            bail!(\"matrix: configure either `access_token` or `password`\");\n        }\n        let ack_reactions = config.ack_reactions.unwrap_or(true);\n        let streaming_state = streaming::State::for_stream_mode(config.stream_mode);\n        Ok(Self {\n            config: Arc::new(config),\n            alias: alias.into(),\n            peer_resolver,\n            state_dir,\n            workspace_dir: None,\n            transcription: None,\n            client: tokio::sync::OnceCell::new(),\n            pending_approvals: Arc::new(TokioMutex::new(HashMap::new())),\n            streaming_state: Arc::new(TokioRwLock::new(streaming_state)),\n            threads_seen: Arc::new(TokioRwLock::new(HashSet::new())),\n            alias_cache: Arc::new(TokioRwLock::new(HashMap::new())),\n            reaction_log: Arc::new(TokioMutex::new(HashMap::new())),\n            bot_display_name: Arc::new(TokioRwLock::new(None)),\n            initial_sync_done: Arc::new(AtomicBool::new(false)),","sourceCodeStart":3980,"sourceCodeEnd":4016,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-channels/src/matrix.rs#L3980-L4016","documentation":"The Matrix channel constructor validates that at least one authentication credential is present: a non-blank `access_token` or a non-blank `password`. Both values are trimmed before the check, so whitespace-only counts as missing. The constructor fails fast rather than starting a listener that could never authenticate to the homeserver.","triggerScenarios":"Constructing a Matrix channel (startup, config load of `[channels.matrix.<alias>]`, or programmatic `new`) with `access_token` absent/blank AND `password` absent/blank.","commonSituations":"New Matrix setup where only homeserver_url and username are filled in; token expected from an env var that is not set or not expanded; TOML key typo like `accessToken`; secret line lost when editing config.","solutions":["Set `access_token` in `[channels.matrix.<alias>]` to a valid Matrix access token","Or set `password` (with the bot username) so the channel can perform password login","Check the key spelling (`access_token`, not `accessToken`) and remove surrounding whitespace-only values","If the token comes from an env var, confirm the variable is exported and correctly referenced"],"exampleFix":"# before\n[channels.matrix.home]\nhomeserver_url = \"https://matrix.org\"\nusername = \"@bot:matrix.org\"\n\n# after\n[channels.matrix.home]\nhomeserver_url = \"https://matrix.org\"\nusername = \"@bot:matrix.org\"\naccess_token = \"syt_...\"   # or: password = \"...\"","handlingStrategy":"validation","validationCode":"let m = &config.channels.matrix;\nlet has_auth = m\n    .access_token\n    .as_deref()\n    .is_some_and(|t| !t.trim().is_empty())\n    || m.password.as_deref().is_some_and(|p| !p.trim().is_empty());\nif !has_auth {\n    return Err(anyhow::anyhow!(\"matrix channel needs access_token or password\"));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate channel config blocks in a startup preflight before constructing any channel","Run config through a schema/lint check in CI that flags matrix blocks without credentials","Prefer access_token over password for long-running bots to avoid login-path failures"],"tags":["matrix","config","credentials","rust"],"backgroundTag":"missing-credentials","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}