libnyanpasu/clash-nyanpasu · warning

remove index on non-sequence item, skipped

Error message

remove index on non-sequence item, skipped

What it means

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.

Source

Thrown at backend/nyanpasu-config/src/runtime/executor/overlay.rs:283

                if current.as_object_arc().is_none() {
                    logs.push(StepLogEntry::warn(format!(
                        "remove path `{dotted}` on non-mapping item, skipped"
                    )));
                    continue;
                }
                let segments = parse_dotted_path(dotted);
                match remove_at(&current, &segments) {
                    Some(next) => current = next,
                    None => logs.push(StepLogEntry::warn(format!(
                        "remove path `{dotted}` not found, skipped"
                    ))),
                }
            }
            ConfigValue::Number(index) => {
                // Legacy numeric removal applies to sequence items only
                // (merge.rs:221 `Value::Sequence(list) if key.is_i64()`).
                if !matches!(current, ConfigValue::Array(_)) {
                    logs.push(StepLogEntry::warn(
                        "remove index on non-sequence item, skipped",
                    ));
                    continue;
                }
                let removed = index
                    .as_u64()
                    .map(|index| index.to_string())
                    .and_then(|segment| remove_at(&current, &[segment]));
                match removed {
                    Some(next) => current = next,
                    None => logs.push(StepLogEntry::warn("remove index invalid, skipped")),
                }
            }
            _ => logs.push(StepLogEntry::warn("invalid remove entry, skipped")),
        }
    }
    current
}

View on GitHub (pinned to f7dbce2997)

Solutions

  1. Apply numeric removal only to items that are arrays (scope via `when`)
  2. Use a string dotted path for mapping items instead
  3. If you meant to remove an item from the parent list, use a parent-level filter instead of an index on the item
  4. Review the filter design: numeric entries index into sequence-typed items only

Example fix

// before
when: "true"
remove: [0]
// after
when: "Array.isArray(item)"
remove: [0]
Defensive patterns

Strategy: type-guard

Validate before calling

// in `when`: only sequence-typed items reach numeric removals
// when: "Array.isArray(item)"

Type guard

fn item_is_sequence(v: &ConfigValue) -> bool { matches!(v, ConfigValue::Array(_)) }

Prevention

When it happens

Trigger: A `remove: [0]` entry is evaluated against an item that is a mapping or scalar rather than a list.

Common situations: 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.

Related errors


AI-assisted analysis of libnyanpasu/clash-nyanpasu@f7dbce2997 (2026-09-08). Data as JSON: /api/errors/55bfc8e788e81519. Report an issue: GitHub.