{"record":{"id":"55bfc8e788e81519","repo":"libnyanpasu/clash-nyanpasu","slug":"remove-index-on-non-sequence-item-skipped","errorCode":null,"errorMessage":"remove index on non-sequence item, skipped","messagePattern":"remove index on non-sequence item, skipped","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"backend/nyanpasu-config/src/runtime/executor/overlay.rs","lineNumber":283,"sourceCode":"                if current.as_object_arc().is_none() {\n                    logs.push(StepLogEntry::warn(format!(\n                        \"remove path `{dotted}` on non-mapping item, skipped\"\n                    )));\n                    continue;\n                }\n                let segments = parse_dotted_path(dotted);\n                match remove_at(&current, &segments) {\n                    Some(next) => current = next,\n                    None => logs.push(StepLogEntry::warn(format!(\n                        \"remove path `{dotted}` not found, skipped\"\n                    ))),\n                }\n            }\n            ConfigValue::Number(index) => {\n                // Legacy numeric removal applies to sequence items only\n                // (merge.rs:221 `Value::Sequence(list) if key.is_i64()`).\n                if !matches!(current, ConfigValue::Array(_)) {\n                    logs.push(StepLogEntry::warn(\n                        \"remove index on non-sequence item, skipped\",\n                    ));\n                    continue;\n                }\n                let removed = index\n                    .as_u64()\n                    .map(|index| index.to_string())\n                    .and_then(|segment| remove_at(&current, &[segment]));\n                match removed {\n                    Some(next) => current = next,\n                    None => logs.push(StepLogEntry::warn(\"remove index invalid, skipped\")),\n                }\n            }\n            _ => logs.push(StepLogEntry::warn(\"invalid remove entry, skipped\")),\n        }\n    }\n    current\n}","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/backend/nyanpasu-config/src/runtime/executor/overlay.rs#L265-L301","documentation":"Numeric entries in a `remove` action apply only to sequence items (index-based removal); if the current item is not an array, the executor skips the entry with a warning, mirroring the legacy match-arm guard.","triggerScenarios":"A `remove: [0]` entry is evaluated against an item that is a mapping or scalar rather than a list.","commonSituations":"Mixed lists where some items are objects and others arrays; misunderstanding that numeric remove targets indexes inside a sequence-typed item, not the item's position in the parent list.","solutions":["Apply numeric removal only to items that are arrays (scope via `when`)","Use a string dotted path for mapping items instead","If you meant to remove an item from the parent list, use a parent-level filter instead of an index on the item","Review the filter design: numeric entries index into sequence-typed items only"],"exampleFix":"// before\nwhen: \"true\"\nremove: [0]\n// after\nwhen: \"Array.isArray(item)\"\nremove: [0]","handlingStrategy":"type-guard","validationCode":"// in `when`: only sequence-typed items reach numeric removals\n// when: \"Array.isArray(item)\"","typeGuard":"fn item_is_sequence(v: &ConfigValue) -> bool { matches!(v, ConfigValue::Array(_)) }","tryCatchPattern":null,"preventionTips":["Pair numeric remove entries with predicates matching only arrays","Use string dotted paths for mapping items","Remember numeric entries index inside a sequence-typed item, not into the parent list"],"tags":["config","filter","remove","sequence"],"backgroundTag":"config-type-mismatch","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"}