{"record":{"id":"498198fb5f3d5d82","repo":"libnyanpasu/clash-nyanpasu","slug":"invalid-filter-missing-when","errorCode":null,"errorMessage":"invalid filter: missing `when`","messagePattern":"invalid filter: missing `when`","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"backend/nyanpasu-config/src/runtime/executor/overlay.rs","lineNumber":176,"sourceCode":"        ConfigValue::Object(actions) => {\n            let Some(ConfigValue::String(when)) = actions.get(\"when\") else {\n                logs.push(StepLogEntry::warn(\"invalid filter: missing `when`\"));\n                return items;\n            };","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/backend/nyanpasu-config/src/runtime/executor/overlay.rs#L158-L194","documentation":"Validation guard in apply_filter for object-form filter rules: a filter expressed as ConfigValue::Object must contain a `when` key holding a string, and when it is absent the filter is rejected. Note this is a soft guard — it logs a StepLogEntry::warn and returns the items unchanged instead of propagating an error, so an invalid filter rule is skipped rather than failing the whole overlay step.","triggerScenarios":"A filter step's filter value is a mapping of actions (merge/remove/override) but has no `when` predicate string.","commonSituations":"Hand-written filter configs omitting `when`; ported legacy merge configs whose action object predates the `when` requirement.","solutions":["Add a `when` predicate expression to the filter object","Check filter syntax: object filters must contain `when` plus an action key","Use a non-object (scalar/array) filter form if no predicate is needed","Enable step logging to confirm which filter block is malformed"],"exampleFix":"// before\nfilter:\n  merge: { extra: true }\n// after\nfilter:\n  when: \"item.name != 'DIRECT'\"\n  merge: { extra: true }","handlingStrategy":"validation","validationCode":"if let ConfigValue::Object(actions) = &filter {\n    assert!(matches!(actions.get(\"when\"), Some(ConfigValue::String(_))), \"filter object requires a `when` string predicate\");\n}","typeGuard":"fn is_valid_object_filter(f: &ConfigValue) -> bool {\n    matches!(f, ConfigValue::Object(a) if matches!(a.get(\"when\"), Some(ConfigValue::String(_))))\n}","tryCatchPattern":null,"preventionTips":["Always include a `when` predicate in object-form filters","Lint overlay filter configs before deployment","Follow current filter schema docs when porting legacy merge configs"],"tags":["config","filter","validation"],"backgroundTag":"missing-required-config-field","analyzedSha":"f7dbce2997c633e484f54788035e770b3ee99773","analyzedAt":"2026-09-08T01:24:59.197Z","contentChangedAt":"2026-09-08T01:24:59.197Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}