{"record":{"id":"8704dce99959ba7c","repo":"astrid-runtime/astrid","slug":"name-must-be-1-64-ascii-characters","errorCode":null,"errorMessage":"{name} must be 1-64 ASCII characters","messagePattern":"(.+?) must be 1-64 ASCII characters","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-emit/src/lib.rs","lineNumber":99,"sourceCode":"    /// (`astrid-emit --topic sage.v1.hook.before_tool_call`).\n    /// Mutually exclusive with the positional form; exactly one is\n    /// required.\n    #[arg(long = \"topic\", value_name = \"TOPIC\")]\n    pub topic_flag: Option<String>,\n}\n\n/// Default wait for a policy hook that needs the broker to accept its frame.\n/// Observation hooks pass `0` to make the transport fire-and-forget.\npub const DEFAULT_POLICY_TIMEOUT_MS: u64 = 1_000;\n\n/// Validate a host/session/event segment before putting it in a bus topic.\n///\n/// These values originate in a host hook payload or command line. Keeping\n/// the check at this boundary prevents a caller from smuggling additional\n/// topic segments into the fixed hook route.\nfn validate_topic_segment(name: &str, value: &str) -> Result<()> {\n    if value.is_empty() || value.len() > 64 {\n        anyhow::bail!(\"{name} must be 1-64 ASCII characters\");\n    }\n    if !value\n        .bytes()\n        .all(|byte| byte.is_ascii_alphanumeric() || matches!(byte, b'_' | b'-'))\n    {\n        anyhow::bail!(\"{name} must contain only ASCII letters, digits, '_' or '-'\");\n    }\n    Ok(())\n}\n\n/// Derive the host hook topic used by the thin `astrid hook` command.\n///\n/// Every host route carries the session as a topic segment. Codex and the\n/// other host runners subscribe to their own `{host}.v1.hook.*.*` namespace;\n/// the envelope itself remains the six-field [`build_envelope`] contract.\n///\n/// # Errors\n/// Returns an error when any segment is empty, too long, or contains a topic","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-emit/src/lib.rs#L81-L117","documentation":"Validation guard in validate_topic_segment, a shared helper guarding hook bus topics: the named segment (host, session, or event) was empty or longer than 64 ASCII characters, which would produce a malformed or oversized topic.","triggerScenarios":"Thrown at crates/astrid-emit/src/lib.rs:99 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Shorten the segment to at most 64 ASCII characters","Supply a non-empty value for the offending segment in the hook payload or CLI argument","Check upstream hook configuration that generates host/session/event values"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}