{"record":{"id":"0841f6616d78678c","repo":"linera-io/linera-protocol","slug":"application-parameters-must-be-deserializable-0841f6","errorCode":null,"errorMessage":"Application parameters must be deserializable","messagePattern":"Application parameters must be deserializable","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"linera-sdk/src/service/runtime.rs","lineNumber":72,"sourceCode":"    pub fn key_value_store(&self) -> KeyValueStore {\n        KeyValueStore::for_services()\n    }\n\n    /// Returns a storage context suitable for a root view.\n    pub fn root_view_storage_context(&self) -> ViewStorageContext {\n        ViewStorageContext::new_unchecked(self.key_value_store(), Vec::new(), ())\n    }\n}\n\nimpl<Application> ServiceRuntime<Application>\nwhere\n    Application: Service,\n{\n    /// Returns the application parameters provided when the application was created.\n    pub fn application_parameters(&self) -> Application::Parameters {\n        Self::fetch_value_through_cache(&self.application_parameters, || {\n            let bytes = base_wit::application_parameters();\n            serde_json::from_slice(&bytes).expect(\"Application parameters must be deserializable\")\n        })\n    }\n\n    /// Returns the ID of the current application.\n    pub fn application_id(&self) -> ApplicationId<Application::Abi> {\n        Self::fetch_value_through_cache(&self.application_id, || {\n            ApplicationId::from(base_wit::get_application_id()).with_abi()\n        })\n    }\n\n    /// Returns the chain ID of the current application creator.\n    pub fn application_creator_chain_id(&self) -> ChainId {\n        Self::fetch_value_through_cache(&self.application_creator_chain_id, || {\n            base_wit::get_application_creator_chain_id().into()\n        })\n    }\n\n    /// Returns the description of the given application.","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-sdk/src/service/runtime.rs#L54-L90","documentation":"ServiceRuntime::application_parameters lazily fetches the creation-time parameters bytes from the host and parses them with serde_json::from_slice::<Application::Parameters>. The expect panics when the stored parameters JSON cannot be decoded into the service's current Parameters type — typically because the application was created with no/different parameters, or the Parameters type changed after publication.","triggerScenarios":"Instantiating the service for an application whose creation parameters were empty or of a different shape than Application::Parameters (e.g. Parameters expects required fields but the app was created with --parameters '{}' or none), or running a service module newer than the one that created the application.","commonSituations":"Deploying a new Parameters struct (new required field) while existing applications were created with the old JSON; forgetting to pass --parameters when publishing; publishing with parameters serialized from a different serde configuration (field renaming, tagged enums); pointing a service at an application created on another network.","solutions":["Publish the application again with valid JSON for the current Parameters type (linera publish-application ... --parameters '<json>') so on-chain creation parameters match","Give every Parameters field a #[serde(default)] or make it Option<T> so empty/legacy parameter objects still decode","Verify the --parameters string is valid JSON and round-trips through Parameters' own Serialize before publishing","If Parameters is genuinely absent, declare it as a unit-like type (struct Parameters;) or Option<Parameters> instead of a struct with required fields"],"exampleFix":"// before: required field panics when app was created without parameters\n#[derive(Serialize, Deserialize)]\nstruct Parameters { admin: AccountOwner }\n\n// after: defaulted field decodes even for legacy instantiations\n#[derive(Serialize, Deserialize)]\nstruct Parameters {\n    #[serde(default)]\n    admin: Option<AccountOwner>,\n}","handlingStrategy":"validation","validationCode":"// Validate creation parameters before publishing.\nfn check_parameters(json: &str) -> Result<(), serde_json::Error> {\n    serde_json::from_str::<Parameters>(json).map(|_| ())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass --parameters with JSON produced by serializing your own Parameters type","Derive Default where sensible and add #[serde(default)] to Parameters fields so legacy apps keep loading","Add a unit test that decodes '{ }' (or the empty-parameters form) into Parameters","After changing Parameters, treat already-deployed apps as needing re-publication"],"tags":["linera","rust","sdk","json","serde","application-parameters"],"backgroundTag":"json-deserialization-error","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}