{"record":{"id":"9e7c2425abc844ea","repo":"linera-io/linera-protocol","slug":"streamnametoolong","errorCode":"StreamNameTooLong","errorMessage":"ExecutionError::StreamNameTooLong","messagePattern":"ExecutionError::StreamNameTooLong","errorType":"exception","errorClass":"ExecutionError","httpStatus":null,"severity":"error","filePath":"linera-execution/src/runtime.rs","lineNumber":1438,"sourceCode":"        argument: Vec<u8>,\n    ) -> Result<Vec<u8>, ExecutionError> {\n        let contract = self\n            .inner()\n            .prepare_for_call(self.clone(), authenticated, callee_id)?;\n\n        let value = contract\n            .try_lock()\n            .expect(\"Applications should not have reentrant calls\")\n            .execute_operation(argument)?;\n\n        self.inner().finish_call();\n\n        Ok(value)\n    }\n\n    fn emit(&mut self, stream_name: StreamName, value: Vec<u8>) -> Result<u32, ExecutionError> {\n        let mut this = self.inner();\n        ensure!(\n            stream_name.0.len() <= MAX_STREAM_NAME_LEN,\n            ExecutionError::StreamNameTooLong\n        );\n        let application_id = GenericApplicationId::User(this.current_application().id);\n        let stream_id = StreamId {\n            stream_name,\n            application_id,\n        };\n        let value_len = value.len() as u64;\n        let index = this\n            .execution_state_sender\n            .send_request(|callback| ExecutionRequest::Emit {\n                stream_id,\n                value,\n                callback,\n            })?\n            .recv_response()?;\n        // TODO(#365): Consider separate event fee categories.","sourceCodeStart":1420,"sourceCodeEnd":1456,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-execution/src/runtime.rs#L1420-L1456","documentation":"ContractRuntime::emit publishes an event on a named stream owned by the calling application. Stream names are raw byte vectors (StreamName(Vec<u8>)) and must be at most MAX_STREAM_NAME_LEN = 64 bytes (linera-execution/src/lib.rs:97). A longer name fails this ensure! deterministically and the transaction aborts; the limit protects stream-index storage, not content size (the event value has its own accounting via track_bytes_written).","triggerScenarios":"Calling runtime.emit(stream_name, value) where stream_name is longer than 64 bytes: names built with format!() from user input, names embedding descriptions or long identifiers, or names copied from another system without the length limit.","commonSituations":"Dynamic stream names constructed from user-supplied strings; multi-byte UTF-8 names that pass a 64-character check in code but exceed 64 bytes on chain; porting an app that used long topic strings; tests with descriptive names that later break on the real runtime.","solutions":["Shorten the stream name to a fixed, descriptive constant of at most 64 bytes.","If a long identifier must be part of the name, hash it (e.g. 32-byte hash encoded compactly) and use the hash as the name, or move the identifier into the event value.","Validate the name at the application's entry point (operation/message decoding) and reject with a clean application error instead of failing mid-execution.","Add a unit test asserting every stream-name constant used by the app is at most 64 bytes."],"exampleFix":"// before\nlet name = format!(\"user-{}-transfers-{}\", user_id, description);\nlet index = runtime.emit(StreamName::from(name.into_bytes()), value)?;\n\n// after\nlet name = format!(\"user-{}-txs\", user_id); // <= 64 bytes by construction\nassert!(name.len() <= 64);\nlet index = runtime.emit(StreamName::from(name.into_bytes()), value)?;","handlingStrategy":"validation","validationCode":"const MAX_STREAM_NAME_LEN: usize = 64;\nif name.as_bytes().len() > MAX_STREAM_NAME_LEN {\n    return Err(AppError::StreamNameTooLong); // fail cleanly before emit\n}\nlet index = runtime.emit(StreamName::from(name.as_bytes().to_vec()), value)?;","typeGuard":"fn is_valid_stream_name(name: &str) -> bool {\n    name.len() <= 64 // byte length, not character count\n}","tryCatchPattern":"match result {\n    Err(ExecutionError::StreamNameTooLong) => {\n        // deterministic input error: surface to caller, never retry\n    }\n    other => other,\n}","preventionTips":["Define stream names once as constants next to the ABI and reuse them everywhere.","Count bytes, not characters: multi-byte UTF-8 inflates the length.","Add a unit test asserting every stream-name constant is at most 64 bytes."],"tags":["linera","events","streams","input-validation","wasm"],"backgroundTag":"input-length-limit-exceeded","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}