Skip to content

Fix array-type filter conditions (ObjectsFilterItem, MultiSelectFilterItem)#2914

Open
themightychris wants to merge 3 commits intoanyproto:developfrom
themightychris:GO-0000-fix-array-filter-conditions
Open

Fix array-type filter conditions (ObjectsFilterItem, MultiSelectFilterItem)#2914
themightychris wants to merge 3 commits intoanyproto:developfrom
themightychris:GO-0000-fix-array-filter-conditions

Conversation

@themightychris
Copy link
Copy Markdown

Summary

Fixes the failed to build expression filters error when using in, all, or nin conditions on array-type properties (objects, multi_select, files) in the Search API.

Problem

The filter item types (ObjectsFilterItem, MultiSelectFilterItem, FilesFilterItem) return []string from their GetValue() methods, but SanitizeAndValidatePropertyValue expected []interface{}. This type assertion failure caused all array-based filter conditions to fail.

Additionally, the links property (a derived system property) was incorrectly validated to require object/member layouts, but it can contain references to any object type (files, types, pages, etc.).

Changes

  • core/api/service/property.go:

    • SanitizeAndValidatePropertyValue now accepts both []string and []interface{} for objects, files, and multi_select property formats
    • Added isValidObjectReferenceForProperty() that relaxes validation for the links property
  • core/api/filter/expression_test.go: Added tests for ObjectsFilterItem with in/all conditions

  • core/api/service/property_test.go: Added tests for SanitizeAndValidatePropertyValue handling []string input for objects and multi_select formats

Test Plan

  • All existing tests pass
  • New tests verify []string input is accepted for objects properties
  • New tests verify []string input is accepted for multi_select properties
  • New tests verify links property accepts any object type (e.g., files)

Fixes #2897

🤖 Generated with Claude Code

@socket-security
Copy link
Copy Markdown

socket-security Bot commented Feb 1, 2026

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

@themightychris themightychris changed the base branch from main to develop February 1, 2026 19:46
@themightychris
Copy link
Copy Markdown
Author

Note: This PR has significant overlap with #2880 by @stevelr, which also fixes the []string type assertion bug for array-type filters.

Differences:

  • Our approach handles []string directly without converting to []interface{}
  • core/api: allow type object ids in type filters #2880 special-cases the type property to allow objectType layout
  • This PR special-cases the links property to allow any object type (files, types, pages, etc.)

Both PRs address the core issue reported in #2897. It may make sense to combine the special cases from both approaches.

themightychris added a commit to themightychris/anytype-heart that referenced this pull request Feb 1, 2026
themightychris added a commit to themightychris/anytype-heart that referenced this pull request Feb 2, 2026
themightychris added a commit to themightychris/anytype-heart that referenced this pull request Feb 2, 2026
themightychris added a commit to themightychris/anytype-heart that referenced this pull request Feb 2, 2026
themightychris added a commit to themightychris/anytype-heart that referenced this pull request Feb 3, 2026
themightychris and others added 3 commits February 2, 2026 21:57
Tests for:
- ObjectsFilterItem with 'in' condition on links property
- ObjectsFilterItem with 'all' condition on assignee property
- SanitizeAndValidatePropertyValue accepting []string input
- links property allowing filtering by any object type

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Bug 1: SanitizeAndValidatePropertyValue now accepts both []string
(from ObjectsFilterItem.GetValue()) and []interface{} (from JSON)
for objects/files property formats.

Bug 2: Added isValidObjectReferenceForProperty() that relaxes
validation for the "links" property - it only checks that the
object exists, without requiring a specific layout. This allows
filtering by any object type (files, types, pages, etc.)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Same bug as ObjectsFilterItem: SanitizeAndValidatePropertyValue
now accepts both []string (from MultiSelectFilterItem.GetValue())
and []interface{} (from JSON) for multi_select property format.

Closes anyproto#2897

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@themightychris themightychris force-pushed the GO-0000-fix-array-filter-conditions branch from 43481ba to bc7dc50 Compare February 3, 2026 02:57
themightychris added a commit to themightychris/anytype-heart that referenced this pull request Feb 3, 2026
themightychris added a commit to themightychris/anytype-heart that referenced this pull request Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Search API filter failure on array-type properties

1 participant