siyuan-note/siyuan · error
filter group requires and/or combination
Error message
filter group requires and/or combination
What it means
This error is thrown when a filter group (a ViewFilter with nested Filters) is submitted with a Combination value that is neither FilterCombinationAnd nor FilterCombinationOr. SiYuan validates relation-filter groups before saving so that stored filter trees always have a well-defined boolean combination. It guards the API setAttributeViewKeyConfig for the 'filters'/'rollupFilters' settings.
Solutions
- Set Combination to av.FilterCombinationAnd ("And") or av.FilterCombinationOr ("Or") on every group filter
- Remove the nested Filters array if the entry was meant to be a leaf filter
- Check the combination value for typos/case before sending
Example fix
// before
{"column":"","combination":"and_all","filters":[{"column":"20240101120000-abc","value":{"content":"x"}}]}
// after
{"column":"","combination":"And","filters":[{"column":"20240101120000-abc","value":{"content":"x"}}]} Defensive patterns
Strategy: validation
Validate before calling
const isGroup = f => Array.isArray(f.filters) && f.filters.length > 0;
for (const f of filters) {
if (isGroup(f) && !(f.combination === "And" || f.combination === "Or")) {
throw new Error(`group filter needs combination And/Or, got ${f.combination}`);
}
} Type guard
const hasValidCombination = (f) => !isFilterGroup(f) || f.combination === "And" || f.combination === "Or";
Prevention
- Always set combination on filters that carry a nested filters array
- Reuse a shared filter-builder helper so groups are constructed with a combination by default
When it happens
Trigger: Calling UpdateAttributeViewKeyConfig (via the kernel API) with setting 'filters' or 'rollupFilters' where an element of the filter array has non-empty Filters (IsGroup() true) but Combination is empty, an unknown string, or any value other than 'And'/'Or'.
Common situations: Building the filter JSON payload by hand and omitting Combination on a nested group; serializing a group from plugin code with a misspelled combination value; API clients that copy a leaf filter shape (no combination) for groups.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- filter nesting depth exceeds the maximum allowed
- invalid attribute view context filter
- validate attribute view context filter target
- at least one visible view is required
- attribute view custom color index
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/3d5df2d18a87970c.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/attribute_view_key_config.go:165
if nil != err {
return err
}
var filters []*av.ViewFilter
if err = decodeAttributeViewKeyConfig(value, &filters); nil != err {
return err
}
if err = av.ValidateFilterDepth(filters); nil != err {
return err
}
var validate func([]*av.ViewFilter) error
validate = func(items []*av.ViewFilter) error {
for _, filter := range items {
if nil == filter {
return errors.New("filter must not be null")
}
if filter.IsGroup() {
if av.FilterCombinationAnd != filter.Combination && av.FilterCombinationOr != filter.Combination {
return errors.New("filter group requires and/or combination")
}
if err := validate(filter.Filters); nil != err {
return err
}
} else if _, err := dest.GetKey(filter.Column); nil != err {
return fmt.Errorf("invalid filter target field: %s", filter.Column)
}
}
return nil
}
return validate(filters)
}
// decodeAttributeViewKeyConfig 拒绝未知字段及空值,防止拼写错误被当作成功更新。
func decodeAttributeViewKeyConfig(value, dest any) error {
if nil == value {
return errors.New("configuration must not be null")
}View on GitHub (pinned to 9f775e8a12)