{"record":{"id":"bf20bd987087f27e","repo":"jdx/mise","slug":"deps-output-rules-should-serialize","errorCode":null,"errorMessage":"deps output rules should serialize","messagePattern":"deps output rules should serialize","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/deps/providers/mod.rs","lineNumber":107,"sourceCode":"            .map(|patterns| self.resolve_path_patterns(patterns, true))\n            .unwrap_or(default)\n    }\n\n    pub(crate) fn optional_outputs(&self, default: Vec<PathBuf>) -> Vec<PathBuf> {\n        if self.config.outputs.is_some() {\n            vec![]\n        } else {\n            default\n        }\n    }\n\n    /// Returns a stable identity for the configured output rules without\n    /// expanding glob matches. This distinguishes omitted defaults, explicit\n    /// replacements, and an explicit empty list while keeping the identity\n    /// unchanged when files matching a glob are added or removed.\n    pub(crate) fn output_rules_hash(&self) -> String {\n        let rules = serde_json::to_string(&(&self.config.dir, &self.config.outputs))\n            .expect(\"deps output rules should serialize\");\n        crate::hash::hash_blake3_to_str(&rules)\n    }\n\n    /// The configured `run` override, or `program` invoked with `args`.\n    /// `description` only applies when the rule doesn't configure one.\n    pub(crate) fn install_command(\n        &self,\n        program: &str,\n        args: &[&str],\n        description: &str,\n    ) -> Result<DepsCommand> {\n        if let Some(run) = &self.config.run {\n            return DepsCommand::from_string(run, &self.project_root, &self.config);\n        }\n        let description = self\n            .config\n            .description\n            .clone()","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/deps/providers/mod.rs#L89-L125","documentation":"mise panics with 'deps output rules should serialize' in `output_rules_hash` when `serde_json::to_string` fails to serialize the dependency provider's configured output directory and rules. Both are plain serializable config types, so serialization should always succeed; this expect documents that any failure is an unrecoverable programming error. The hash gives output rules a stable identity used to detect whether declared rules changed versus glob matches appearing/disappearing.","triggerScenarios":"Adding a non-serializable type (e.g. a map with non-string keys, an untagged enum variant, or a type missing `Serialize`) to `DepProviderConfig::dir` or `outputs` so `serde_json::to_string` returns an error; a serde attribute change (like `skip_serializing_if` interplay or custom serializer returning Err) on those fields.","commonSituations":"A contributor extends the deps provider config with a new output-rule field and forgets to derive/implement `Serialize`, or uses a type JSON cannot represent (e.g. `PathBuf` keys in a HashMap).","solutions":["Ensure `dir` and every `outputs` rule variant derive/implement `serde::Serialize` with JSON-compatible types","Avoid non-string map keys or custom serializers that can fail in the rule types","Match on the serialization error and wrap it in a user-facing error instead of `expect` if new fallible types are unavoidable","Re-run `output_rules_hash_tracks_declared_rules_not_glob_matches` after changing the rule types"],"exampleFix":"// before\n#[derive(Debug)]\npub struct OutputRule { pub glob: String, pub action: Action }\n// after\n#[derive(Debug, serde::Serialize)]\npub struct OutputRule { pub glob: String, pub action: Action }","handlingStrategy":"validation","validationCode":"serde_json::to_string(&(&cfg.dir, &cfg.outputs)).expect(\"output rules must be JSON-serializable\"); // run in a unit test","typeGuard":"fn serializable<T: serde::Serialize>(v: &T) -> bool { serde_json::to_string(v).is_ok() }","tryCatchPattern":"match serde_json::to_string(&value) { Ok(s) => s, Err(e) => return Err(e.into()) }","preventionTips":["Derive Serialize on every new deps output-rule config type","Keep field types JSON-compatible (string keys, serializable enums)","Add a unit test hashing sample configs whenever rule types change"],"tags":["rust","serde","json","deps","panic"],"backgroundTag":"json-serialization-failed","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}