feat(base): add +record-search for keyword-based record search#328
feat(base): add +record-search for keyword-based record search#328
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a new Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI runtime
participant Shortcut as +record-search Shortcut
participant Parser as JSON parser
participant BaseAPI as Base API (records/search)
CLI->>Shortcut: invoke +record-search (--base-token, --table-id, --json)
Shortcut->>Parser: parse `--json` body
alt parse success
Shortcut->>BaseAPI: POST /open-apis/base/v3/bases/:base_token/tables/:table_id/records/search (body)
BaseAPI-->>Shortcut: 200 OK (records payload)
Shortcut-->>CLI: write records to stdout
else parse failure
Shortcut-->>CLI: return parse error
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Greptile SummaryThis PR adds the Confidence Score: 5/5Safe to merge — new shortcut is additive, well-tested, and consistent with existing patterns. No P0 or P1 findings. All remaining observations from prior threads appear resolved (no No files require special attention.
|
| Filename | Overview |
|---|---|
| shortcuts/base/record_search.go | New shortcut definition for +record-search; correctly marks all flags as required, sets risk to read, and wires dry-run and execute handlers. |
| shortcuts/base/record_ops.go | Adds dryRunRecordSearch and executeRecordSearch; both call parseJSONObject directly (no unnecessary wrapper), consistent with upsert pattern; execute properly returns parse/API errors. |
| shortcuts/base/shortcuts.go | Inserts BaseRecordSearch between BaseRecordList and BaseRecordGet in the catalog, matching the updated test expectation and intended ordering. |
| shortcuts/base/record_upsert.go | Removes the Validate field from BaseRecordUpsert, aligning upsert with the API-passthrough philosophy; test asserts Validate == nil. |
| shortcuts/base/base_dryrun_ops_test.go | Adds dry-run assertion for record search; uses offset:-1 and limit:500 intentionally to prove CLI does not clamp/validate passthrough values. |
| shortcuts/base/base_execute_test.go | Adds an execute test that stubs the POST search endpoint, runs the shortcut, and verifies both stdout and the captured request body contain the expected fields. |
| shortcuts/base/base_shortcuts_test.go | Updates catalog order test to include +record-search, and adds a Validate == nil assertion for both the new search shortcut and the modified upsert shortcut. |
| skills/lark-base/references/lark-base-record-search.md | New reference doc; covers parameters, constraints, usage examples, caveats and cross-references; filter field is absent from the JSON format table (noted in a prior thread). |
| skills/lark-base/SKILL.md | Adds +record-search to the command index and updates the record commands row in the quick-reference table. |
Sequence Diagram
sequenceDiagram
participant User
participant CLI as lark-cli base +record-search
participant Parser as parseJSONObject
participant API as Lark Base API
User->>CLI: --base-token --table-id --json '{...}'
alt --dry-run flag
CLI->>Parser: parseJSONObject(json)
Parser-->>CLI: body (error discarded)
CLI-->>User: POST /open-apis/base/v3/bases/:base_token/tables/:table_id/records/search + body preview
else execute
CLI->>Parser: parseJSONObject(json)
Parser-->>CLI: body, err
alt parse error
CLI-->>User: error returned
else valid JSON object
CLI->>API: POST /open-apis/base/v3/bases/{base_token}/tables/{table_id}/records/search
API-->>CLI: {code, data: {fields, record_id_list, data, has_more, query_context}}
CLI-->>User: JSON output
end
end
Reviews (7): Last reviewed commit: "fix: align record search JSON parsing wi..." | Re-trigger Greptile
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@02ff0365056ec79c3467436ffb30793269114772🧩 Skill updatenpx skills add larksuite/cli#feat-search-record -y -g |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
shortcuts/base/record_ops.go (1)
162-167: Consider removing trivial wrapper.
parseRecordSearchBodyis a pass-through toparseJSONObjectwith no additional logic. You could callparseJSONObject(runtime.Str("json"), "json")directly indryRunRecordSearchandexecuteRecordSearch, matching the pattern used indryRunRecordUpsert(line 47) andexecuteRecordUpsert(line 131).If you're keeping this for future search-specific validation, that's fine too.
♻️ Optional: inline the calls
func dryRunRecordSearch(_ context.Context, runtime *common.RuntimeContext) *common.DryRunAPI { - body, _ := parseRecordSearchBody(runtime) + body, _ := parseJSONObject(runtime.Str("json"), "json") return common.NewDryRunAPI().func executeRecordSearch(runtime *common.RuntimeContext) error { - body, err := parseRecordSearchBody(runtime) + body, err := parseJSONObject(runtime.Str("json"), "json") if err != nil {Then remove
parseRecordSearchBodyentirely.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@shortcuts/base/record_ops.go` around lines 162 - 167, parseRecordSearchBody is a trivial passthrough to parseJSONObject and can be removed; replace calls to parseRecordSearchBody(...) in dryRunRecordSearch and executeRecordSearch with direct calls to parseJSONObject(runtime.Str("json"), "json") (mirroring the pattern used by dryRunRecordUpsert and executeRecordUpsert), and then delete the parseRecordSearchBody function unless you intend to add search-specific validation later.
🤖 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-base/references/lark-base-record-search.md`:
- Around line 39-41: The fenced code block containing the API path "POST
/open-apis/base/v3/bases/:base_token/tables/:table_id/records/search" should
include a language tag to satisfy markdownlint MD040; update the backtick fence
around that path to use a language identifier (e.g., http) so the block becomes
a labeled code fence for the API path.
- Around line 45-53: Add a row documenting the optional `filter` field in the
JSON schema table in lark-base-record-search.md: state field name `filter`, 必填
否, 类型 object (JSON), 约束 指定为合法 JSON 对象并遵循文档中“JSON 格式要求”规则(例如允许的表达式/字段格式),并 note
it may be omitted; ensure the description matches examples that use `filter` so
payload shape is unambiguous.
---
Nitpick comments:
In `@shortcuts/base/record_ops.go`:
- Around line 162-167: parseRecordSearchBody is a trivial passthrough to
parseJSONObject and can be removed; replace calls to parseRecordSearchBody(...)
in dryRunRecordSearch and executeRecordSearch with direct calls to
parseJSONObject(runtime.Str("json"), "json") (mirroring the pattern used by
dryRunRecordUpsert and executeRecordUpsert), and then delete the
parseRecordSearchBody function unless you intend to add search-specific
validation later.
🪄 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: a1b4139e-565d-44f8-9ff3-408e83db0fbe
📒 Files selected for processing (10)
shortcuts/base/base_dryrun_ops_test.goshortcuts/base/base_execute_test.goshortcuts/base/base_shortcuts_test.goshortcuts/base/record_ops.goshortcuts/base/record_search.goshortcuts/base/shortcuts.goskills/lark-base/SKILL.mdskills/lark-base/references/lark-base-record-list.mdskills/lark-base/references/lark-base-record-search.mdskills/lark-base/references/lark-base-record.md
There was a problem hiding this comment.
♻️ Duplicate comments (2)
skills/lark-base/references/lark-base-record-search.md (2)
39-41:⚠️ Potential issue | 🟡 MinorAdd a language tag to the API path code fence.
This fenced block is unlabeled and can fail markdownlint
MD040. Use an explicit language (e.g.,http).Suggested patch
-``` +```http POST /open-apis/base/v3/bases/:base_token/tables/:table_id/records/search</details> <details> <summary>🤖 Prompt for AI Agents</summary>Verify each finding against the current code and only fix it if needed.
In
@skills/lark-base/references/lark-base-record-search.mdaround lines 39 - 41,
The unlabeled fenced code block containing the API path "POST
/open-apis/base/v3/bases/:base_token/tables/:table_id/records/search" should
include a language tag to satisfy markdownlint MD040; update the fence fromtohttp so it reads as a labeled http code block, preserving the exact API
path text inside the fence.</details> --- `45-52`: _⚠️ Potential issue_ | _🟡 Minor_ **Document `filter` in the JSON schema table for payload completeness.** `filter` is supported in request bodies but is absent from the table, which makes payload shape ambiguous. <details> <summary>Suggested patch</summary> ```diff | `search_fields` | 是 | string[] | 数组长度 `1-20`;每项是字段 `field_id` 或字段名,代表在这些字段中做关键词搜索 | | `select_fields` | 否 | string[] | 数组长度 `<=50`;每项是字段 `field_id` 或字段名 | +| `filter` | 否 | object | 过滤条件对象(如 `conjunction` / `conditions`),可省略 | | `offset` | 否 | int | `>=0`,默认 `0` | | `limit` | 否 | int | `1-200`,默认 `10` | ``` </details> <details> <summary>🤖 Prompt for AI Agents</summary> ``` Verify each finding against the current code and only fix it if needed. In `@skills/lark-base/references/lark-base-record-search.md` around lines 45 - 52, Add the missing `filter` row to the JSON schema table in lark-base-record-search.md: document `filter` as an optional field named `filter`, type "object" (or "string"/JSON expression if your API accepts serialized filters), and describe constraints/shape (e.g., allowed operators, nested structure, or reference to the filter schema used elsewhere), and note any size/complexity limits; ensure the new row sits alongside `view_id`, `keyword`, `search_fields`, etc., and include a brief cross-reference to the canonical filter schema or example usage so payload shape is unambiguous. ``` </details> </blockquote></details> </blockquote></details> <details> <summary>🤖 Prompt for all review comments with AI agents</summary>Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In@skills/lark-base/references/lark-base-record-search.md:
- Around line 39-41: The unlabeled fenced code block containing the API path
"POST /open-apis/base/v3/bases/:base_token/tables/:table_id/records/search"
should include a language tag to satisfy markdownlint MD040; update the fence
fromtohttp so it reads as a labeled http code block, preserving the
exact API path text inside the fence.- Around line 45-52: Add the missing
filterrow to the JSON schema table in
lark-base-record-search.md: documentfilteras an optional field named
filter, type "object" (or "string"/JSON expression if your API accepts
serialized filters), and describe constraints/shape (e.g., allowed operators,
nested structure, or reference to the filter schema used elsewhere), and note
any size/complexity limits; ensure the new row sits alongsideview_id,
keyword,search_fields, etc., and include a brief cross-reference to the
canonical filter schema or example usage so payload shape is unambiguous.</details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: defaults **Review profile**: CHILL **Plan**: Pro **Run ID**: `faa04148-e356-4d08-a8c8-8bda361ca991` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 38556f5aa4444eaf869705e547b362d57b8e01e2 and 037a1c43706c7cfaa9bb319976429f4c10e1c9d0. </details> <details> <summary>📒 Files selected for processing (3)</summary> * `skills/lark-base/SKILL.md` * `skills/lark-base/references/lark-base-record-list.md` * `skills/lark-base/references/lark-base-record-search.md` </details> <details> <summary>✅ Files skipped from review due to trivial changes (1)</summary> * skills/lark-base/references/lark-base-record-list.md </details> <details> <summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary> * skills/lark-base/SKILL.md </details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
There was a problem hiding this comment.
kongenpei has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
There was a problem hiding this comment.
kongenpei has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
There was a problem hiding this comment.
kongenpei has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
|
close #143 |
Summary
Add a new
base +record-searchshortcut to pass through JSON payloads to the Base records search API, with dry-run support and test/doc coverage.Changes
+record-searchshortcut registration and execution for Base records search./records/searchendpoint.skills/lark-basedocs and references for+record-searchusage.Test Plan
make unit-test)lark xxxcommand works as expected (go run . base +record-search --base-token app_token --table-id tbl_token --json '{}' --dry-run)go mod tidy(no changes togo.mod/go.sum)go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6 run --new-from-rev=origin/main(local env reports an existing unrelatedforbidigoissue inshortcuts/drive/drive_upload.go:186)Related Issues
Summary by CodeRabbit
New Features
Documentation
Behavior
Tests