Skip to content

fix(base): confirm table URL selections - #2128

Open
zhouyue-bytedance wants to merge 1 commit into
larksuite:mainfrom
zhouyue-bytedance:fix/base-url-resolve-table-confirm
Open

fix(base): confirm table URL selections#2128
zhouyue-bytedance wants to merge 1 commit into
larksuite:mainfrom
zhouyue-bytedance:fix/base-url-resolve-table-confirm

Conversation

@zhouyue-bytedance

@zhouyue-bytedance zhouyue-bytedance commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fix a Base +url-resolve regression after #2099 where a normal table URL stayed as an unconfirmed block_id when blocks/list did not return the selected table.

Changes

  • Keep blocks/list as the first resolver for dashboard/workflow/folder/docx selections.
  • If the block list does not confirm the selected id, call GET /bases/{base}/tables/{selected} to confirm normal table selections and then restore block_type=table, table_id, and table-only URL coordinates such as view_id.
  • Add resolver and dry-run tests for the table fallback path.

Test Plan

Summary by CodeRabbit

  • Bug Fixes
    • Improved Base and Wiki URL resolution when the selected table is missing from the initial block listing.
    • Table details, including its name, coordinates, type, and fields, are now retrieved directly when needed.
    • Mismatched table responses are rejected to ensure the correct table is resolved.
    • Dry-run plans now accurately include the fallback table metadata request.

@github-actions github-actions Bot added domain/base PR touches the base domain size/M Single-domain feat or fix with limited business impact labels Jul 31, 2026
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: afe1e091-79fc-42ba-a209-1d7139f80c2c

📥 Commits

Reviewing files that changed from the base of the PR and between 472bd9d and 9eefd68.

📒 Files selected for processing (3)
  • shortcuts/base/base_resolve.go
  • shortcuts/base/base_resolve_test.go
  • tests/cli_e2e/base/base_url_resolve_dryrun_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • shortcuts/base/base_resolve_test.go
  • tests/cli_e2e/base/base_url_resolve_dryrun_test.go
  • shortcuts/base/base_resolve.go

📝 Walkthrough

Walkthrough

BaseURLResolve now requests table-read authorization and uses a table-detail lookup when block listing omits the selected table. Dry-run plans and tests cover Base and Wiki URL resolution.

Changes

Base table fallback resolution

Layer / File(s) Summary
Fallback contract and dry-run flow
shortcuts/base/base_resolve.go, tests/cli_e2e/base/base_url_resolve_dryrun_test.go
The resolver requests base:table:read. Base and Wiki dry-run plans include table-detail GET requests after block listing.
Runtime table-detail resolution and validation
shortcuts/base/base_resolve.go, shortcuts/base/base_resolve_test.go
Runtime resolution fetches the selected table when block listing does not identify it. The result includes table metadata and URL selections. Tests verify coordinates and the table name.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant BaseURLResolve
  participant BlockListAPI
  participant TableDetailAPI
  BaseURLResolve->>BlockListAPI: list Base blocks
  BaseURLResolve->>TableDetailAPI: fetch selected table by ID
  TableDetailAPI-->>BaseURLResolve: return table metadata
  BaseURLResolve->>BaseURLResolve: apply URL selections
Loading

Possibly related PRs

  • larksuite/cli#1338: Introduces the BaseURLResolve implementation extended by this change.
  • larksuite/cli#2078: Modifies the Base URL resolution flow in the same source file.
  • larksuite/cli#2099: Modifies related block-list and table-fallback logic with corresponding tests.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the Base URL selection fix and matches the main change.
Description check ✅ Passed The description includes the required summary, changes, test plan, and related issues sections with sufficient detail.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@shortcuts/base/base_resolve.go`:
- Around line 525-533: Update resolveSelectedBaseTable to reject nil or empty
table data before accessing or assigning fields, returning found=false for
missing or identity-less responses instead of synthesizing a table from tableID.
At the baseV3Call API boundary, unmarshal the successful response into the
appropriate typed table struct, then return that typed table only when a valid
payload is present.
🪄 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 Plus

Run ID: f7624f34-d038-4e12-b17c-0c317791efa2

📥 Commits

Reviewing files that changed from the base of the PR and between cfe76ad and 472bd9d.

📒 Files selected for processing (3)
  • shortcuts/base/base_resolve.go
  • shortcuts/base/base_resolve_test.go
  • tests/cli_e2e/base/base_url_resolve_dryrun_test.go

Comment thread shortcuts/base/base_resolve.go Outdated
Comment on lines +525 to +533
func resolveSelectedBaseTable(runtime *common.RuntimeContext, baseToken, tableID string) (map[string]interface{}, bool) {
table, err := baseV3Call(runtime, "GET", baseV3Path("bases", baseToken, "tables", tableID), nil, nil)
if err != nil {
return nil, false
}
if strings.TrimSpace(common.GetString(table, "id")) == "" {
table["id"] = tableID
}
return table, true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -A80 -B20 \
  'func baseV3Call|func handleBaseAPIResult|func baseV3Path' .

rg -n -A40 -B10 \
  'executeTableGet|baseV3Call\(runtime, "GET"|tableGetResolveStub' shortcuts/base

Repository: larksuite/cli

Length of output: 50369


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== base_resolve.go relevant section =="
sed -n '490,550p' shortcuts/base/base_resolve.go

echo "== table_get.go =="
sed -n '1,140p' shortcuts/base/table_get.go

echo "== tests mentioning resolveSelectedBaseTable/tableGet or table id =="
rg -n -A20 -B10 'resolveSelectedBaseTable|tableGetResolveStub|executeTableGet|tbl[A-Za-z0-9]*' shortcuts/base --glob '*_test.go' || true

echo "== local shell verification of relevant Go snippets behavior =="
python3 - <<'PY'
import json, re
from pathlib import Path
p = Path("shortcuts/base/base_resolve.go")
s = p.read_text()
m = re.search(r'func resolveSelectedBaseTable\(.*?\n\}', s, re.S)
print("found resolveSelectedBaseTable:", bool(m))
if m:
    print(m.group(0))
PY

Repository: larksuite/cli

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== base_resolve.go line count =="
wc -l shortcuts/base/base_resolve.go

echo "== base_resolve.go relevant section =="
sed -n '500,545p' shortcuts/base/base_resolve.go

echo "== table_get.go =="
sed -n '1,130p' shortcuts/base/table_get.go

echo "== resolveSelectedBaseTable references =="
rg -n -A35 -B10 'resolveSelectedBaseTable\(' shortcuts/base --glob '*.go'

echo "== table-get focused tests only =="
rg -n -A35 -B10 'BaseTableGet|executeTableGet|/open-apis/base/v3/bases/app_x/tables/tbl_x"|/open-apis/base/v3/bases/app_x/tables/Tests"|code": 0.*"data":\{' shortcuts/base --glob '*_test.go' | sed -n '1,220p'

echo "== deterministic map write semantics probe =="
python3 - <<'PY'
print("Python nil write example (Golang nil map panics in same situation):")
try:
    table = None
    table["id"] = "tbl_x"
except Exception as e:
    print(type(e).__name__, str(e))
print("Successful map exists:")
table = {}
table["id"] = "tbl_x"
print(table)
PY

Repository: larksuite/cli

Length of output: 19768


Reject nil or identity-less table responses.

handleBaseAPIResultAny unwraps a successful code: 0 envelope to data; if that value is nil, resolveSelectedBaseTable returns found=true and panics on the assignment at table["id"] = tableID. If data is an empty map, it promotes tableID to a returned table object even though the table payload is absent. Return found=false for nil/empty data instead, and parse the table into a typed table struct at the API boundary.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@shortcuts/base/base_resolve.go` around lines 525 - 533, Update
resolveSelectedBaseTable to reject nil or empty table data before accessing or
assigning fields, returning found=false for missing or identity-less responses
instead of synthesizing a table from tableID. At the baseV3Call API boundary,
unmarshal the successful response into the appropriate typed table struct, then
return that typed table only when a valid payload is present.

Sources: Coding guidelines, Learnings

@zhouyue-bytedance
zhouyue-bytedance force-pushed the fix/base-url-resolve-table-confirm branch from 472bd9d to 9eefd68 Compare July 31, 2026 03:12
@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add zhouyue-bytedance/cli#fix/base-url-resolve-table-confirm -y -g

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/base PR touches the base 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.

1 participant