Skip to content

feat: add support for additional search filters#353

Merged
fangshuyu-768 merged 1 commit intomainfrom
refactor/search-filter-support
Apr 8, 2026
Merged

feat: add support for additional search filters#353
fangshuyu-768 merged 1 commit intomainfrom
refactor/search-filter-support

Conversation

@wittam-01
Copy link
Copy Markdown
Collaborator

@wittam-01 wittam-01 commented Apr 8, 2026

Change-Id: Ib5b06e2df513a835a79a295c45ef1637413afa4e

Summary

Add support for additional docs +search --filter fields and make filter routing explicit for doc-scoped and wiki-scoped searches. This change prevents invalid mixed-scope requests, improves request construction for
folder_tokens and space_ids, and updates the skill documentation so agents can use the new search capabilities correctly.

Changes

  • Update docs +search request building so folder_tokens is only sent to doc_filter, space_ids is only sent to wiki_filter, and requests containing both are rejected with a validation error
  • Add unit tests covering doc-only filter routing, wiki-only filter routing, opposite-scope key stripping, and mixed-scope conflict validation
  • Expand lark-doc-search skill documentation with additional --query examples, supported --filter fields, scope-specific filter behavior, and usage guidance for agent handoff scenarios

Test Plan

  • Unit tests pass
  • Manual local verification confirms the lark docs +search command works as expected

Related Issues

  • None

Summary by CodeRabbit

  • New Features

    • Search now recognizes additional entity types (BITABLE, FOLDER) in doc/wiki results.
  • Improvements

    • Prevents combining document-scoped and wiki-scoped filters in one query.
    • Filter propagation now splits public fields between doc and wiki scopes and auto-fills scope-specific filters when appropriate.
  • Tests

    • Added unit tests covering filter-splitting and conflict handling.
  • Documentation

    • Expanded advanced query examples and a detailed filter field reference.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

📝 Walkthrough

Walkthrough

Modified request-building to enforce doc vs wiki filter scoping: detect non-empty folder_tokens or space_ids, reject when both present, clone and strip opposing scope keys, and conditionally set doc_filter/wiki_filter. Documentation and tests updated accordingly.

Changes

Cohort / File(s) Summary
Filter Scoping Logic
shortcuts/doc/docs_search.go
Added helpers to detect non-empty filter arrays and clone maps; buildDocsSearchRequest now validates that folder_tokens and space_ids are not both provided, clones the parsed filter, removes opposing scope keys, and sets doc_filter and/or wiki_filter conditionally.
Test Coverage
shortcuts/doc/docs_search_test.go
Added unit tests covering: folder_tokens-only behavior, space_ids-only behavior, rejection when both keys present, and behavior when one scoped key is empty (opposing key stripped).
Documentation
skills/lark-doc/references/lark-doc-search.md
Expanded docs with advanced --query syntax examples, detailed --filter field mappings (doc vs wiki vs shared), mutual-exclusivity rule for folder_tokens/space_ids, entity resolution notes, and added supported entity types (BITABLE, FOLDER).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

documentation

Suggested reviewers

  • fangshuyu-768

Poem

🐰 I hopped through filters, tidy and bright,
Folder here, space there — separate light.
No double paths tangled in one chase,
Tests and docs help keep a neat place,
A rabbit cheers the scoped-search race! 🥕

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is partially related to the changeset but overly broad—it mentions 'additional search filters' without specifying the core change of making filter routing explicit and preventing mixed-scope requests, which is the main point of the PR. Consider a more specific title like 'feat: add filter routing for doc-scoped and wiki-scoped searches' to better reflect the main architectural change.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The PR description is comprehensive and follows the template with all required sections (Summary, Changes, Test Plan, Related Issues) properly filled out with detailed information.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/search-filter-support

Comment @coderabbitai help to get the list of available commands and usage tips.

@wittam-01 wittam-01 requested a review from fangshuyu-768 April 8, 2026 15:11
@github-actions github-actions bot added domain/ccm PR touches the ccm domain size/M Single-domain feat or fix with limited business impact labels Apr 8, 2026
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 8, 2026

Greptile Summary

This PR adds explicit filter routing for docs +search: folder_tokens is now sent only to doc_filter, space_ids only to wiki_filter, and supplying both together is rejected with a validation error. Corresponding unit tests and expanded skill documentation are included.

The implementation is correct and well-tested. The shallow-clone and omitted-counterpart-filter concerns raised in prior review threads remain as-is (no change from the original review), but no new P0/P1 issues were found in this revision.

Confidence Score: 5/5

Safe to merge — all remaining findings are P2 or lower; the routing logic is correct and fully covered by tests.

The only open concerns (shallow clone sharing nested map references, and whether omitting the counterpart filter leaks results from the other scope) were surfaced in prior review threads and left as acknowledged trade-offs. No new P0 or P1 issues were found. Tests exercise all four new branches; documentation is thorough.

No files require special attention.

Vulnerabilities

No security concerns identified. The filter routing change is read-only (search API), input is validated via json.Unmarshal before use, and the conflict check prevents malformed mixed-scope requests.

Important Files Changed

Filename Overview
shortcuts/doc/docs_search.go Adds filter routing logic: folder_tokensdoc_filter only, space_idswiki_filter only, with conflict validation; introduces cloneFilterMap (shallow) and hasNonEmptyFilterArray helpers.
shortcuts/doc/docs_search_test.go Adds four targeted tests for doc-only routing, wiki-only routing, opposite-key stripping, and mixed-scope conflict validation; all new paths are covered.
skills/lark-doc/references/lark-doc-search.md Substantial documentation expansion: adds Boolean query syntax examples, comprehensive --filter field reference, scope-attribution table, usage guidance, and handoff rules for agents.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["buildDocsSearchRequest(query, filterStr, pageToken, pageSizeStr)"] --> B{filterStr empty?}
    B -- Yes --> C["doc_filter = {}\nwiki_filter = {}\nreturn"]
    B -- No --> D[Parse JSON filter]
    D --> E[convertTimeRangeInFilter\nopen_time / create_time]
    E --> F{Both folder_tokens\nAND space_ids set?}
    F -- Yes --> G[return ErrValidation\n'cannot combine both']
    F -- No --> H["docFilter = clone(filter) - space_ids\nwikiFilter = clone(filter) - folder_tokens"]
    H --> I{hasFolderTokens?}
    I -- Yes --> J["requestData['doc_filter'] = docFilter\n(wiki_filter omitted)"]
    I -- No --> K{hasSpaceIDs?}
    K -- Yes --> L["requestData['wiki_filter'] = wikiFilter\n(doc_filter omitted)"]
    K -- No --> M["requestData['doc_filter'] = docFilter\nrequestData['wiki_filter'] = wikiFilter"]
    J --> N[return requestData]
    L --> N
    M --> N
Loading

Reviews (2): Last reviewed commit: "feat: add support for additional search ..." | Re-trigger Greptile

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@ff72ba6b28bfeeb55f851968f886e1992d670e73

🧩 Skill update

npx skills add larksuite/cli#refactor/search-filter-support -y -g

Change-Id: Ib5b06e2df513a835a79a295c45ef1637413afa4e
@wittam-01 wittam-01 force-pushed the refactor/search-filter-support branch from 91b9b1b to ff72ba6 Compare April 8, 2026 15:19
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@skills/lark-doc/references/lark-doc-search.md`:
- Around line 119-147: Update the conflict wording for folder_tokens and
space_ids to state the runtime rule: the shortcut rejects only when both
folder_tokens and space_ids are provided as non-empty arrays (i.e., "both
non-empty"), not merely when both keys exist; change the short table note
(`两者不能同时传`) and the later sentence that currently reads `如果同时传 folder_tokens 和
space_ids,shortcut 直接报错,不支持...` to explicitly say the error occurs only if both
arrays are non-empty, and keep references to the terms folder_tokens and
space_ids so readers can locate the two places to edit.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7c744ec1-785d-4bee-a5d7-7640d650849d

📥 Commits

Reviewing files that changed from the base of the PR and between 91b9b1b and ff72ba6.

📒 Files selected for processing (3)
  • shortcuts/doc/docs_search.go
  • shortcuts/doc/docs_search_test.go
  • skills/lark-doc/references/lark-doc-search.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • shortcuts/doc/docs_search_test.go

@fangshuyu-768 fangshuyu-768 merged commit 9fab62b into main Apr 8, 2026
17 checks passed
@fangshuyu-768 fangshuyu-768 deleted the refactor/search-filter-support branch April 8, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/ccm PR touches the ccm domain size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants