{"record":{"id":"6602d1e2247813d7","repo":"vectordotdev/vector","slug":"valid-message-key","errorCode":null,"errorMessage":"valid message key","messagePattern":"valid message key","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/codecs/src/decoding/format/syslog.rs","lineNumber":69,"sourceCode":"            source: self.source,\n            lossy: self.syslog.lossy,\n        }\n    }\n\n    /// Return the type of event build by this deserializer.\n    pub fn output_type(&self) -> DataType {\n        DataType::Log\n    }\n\n    /// The schema produced by the deserializer.\n    pub fn schema_definition(&self, log_namespace: LogNamespace) -> schema::Definition {\n        match (log_namespace, self.source) {\n            (LogNamespace::Legacy, _) => {\n                let mut definition = schema::Definition::empty_legacy_namespace()\n                    // The `message` field is always defined. If parsing fails, the entire body becomes the\n                    // message.\n                    .with_event_field(\n                        log_schema().message_key().expect(\"valid message key\"),\n                        Kind::bytes(),\n                        Some(\"message\"),\n                    );\n\n                if let Some(timestamp_key) = log_schema().timestamp_key() {\n                    // All other fields are optional.\n                    definition = definition.optional_field(\n                        timestamp_key,\n                        Kind::timestamp(),\n                        Some(\"timestamp\"),\n                    )\n                }\n\n                definition = definition\n                    .optional_field(&owned_value_path!(\"hostname\"), Kind::bytes(), Some(\"host\"))\n                    .optional_field(\n                        &owned_value_path!(\"severity\"),\n                        Kind::bytes(),","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/lib/codecs/src/decoding/format/syslog.rs#L51-L87","documentation":"`schema_definition` builds the output schema for the syslog decoder and calls `log_schema().message_key().expect(\"valid message key\")`, asserting that the global log schema always defines a `message` key. In the Legacy log namespace the `message` field is mandatory, so if the schema provider returns None the assumption is broken and the process panics.","triggerScenarios":"Calling `schema_definition` (any use of the syslog decoder's schema, e.g. during topology build or schema validation) while the global `log_schema()` has no `message_key` configured — essentially only under non-standard global schema customization.","commonSituations":"Tests or embedders that replace/override Vector's default log schema without a `message` key; unusual feature-flag combinations that alter `log_schema()` defaults.","solutions":["Ensure the global log schema keeps its default `message` key (don't strip required keys from `log_schema()`)","If customizing the schema programmatically, always set a message key before building components","Refactor the codec to handle an optional message key instead of `expect`"],"exampleFix":"// before\nlog_schema().message_key().expect(\"valid message key\")\n// after\nlet message_key = log_schema().message_key().unwrap_or_else(|| \"message\".into());","handlingStrategy":"validation","validationCode":"// Rust, before building components with a customized schema\nlet schema = log_schema();\nassert!(schema.message_key().is_some(), \"global log schema must define a message key\");","typeGuard":"fn has_message_key(schema: &LogSchema) -> bool {\n    schema.message_key().is_some()\n}","tryCatchPattern":"let key = log_schema().message_key()\n    .unwrap_or_else(|| Bytes::from_static(b\"message\")); // fallback instead of expect","preventionTips":["Do not strip required keys (message, timestamp) when customizing log_schema()","Run topology/schema validation tests after any global schema change","Handle Option returns defensively in codec code rather than expect-ing"],"tags":["rust","syslog","schema","invariant","decoding"],"backgroundTag":"internal-invariant-violation","analyzedSha":"bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013","analyzedAt":"2026-09-16T02:53:35.741Z","contentChangedAt":"2026-09-16T02:53:35.741Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}