Skip to content

fix(wiki): surface real node url for +node-create / +node-copy#960

Merged
fangshuyu-768 merged 2 commits into
mainfrom
fix/wiki-node-url
May 19, 2026
Merged

fix(wiki): surface real node url for +node-create / +node-copy#960
fangshuyu-768 merged 2 commits into
mainfrom
fix/wiki-node-url

Conversation

@liujinkun2025

@liujinkun2025 liujinkun2025 commented May 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

The create-node and copy-node OpenAPI responses carry a real url field (present in practice, even though it is not in Feishu's documented node schema). Both shortcuts ignored it:

  • +node-create synthesized a link via BuildResourceURL (host + /wiki/ + token).
  • +node-copy emitted no URL at all.

This change makes both shortcuts prefer the canonical URL returned by the API:

  • Parse url into the shared wikiNodeRecord.
  • Add a wikiNodeURL(brand, node) helper that returns the response url when present and falls back to BuildResourceURL synthesis only when it is blank/absent.
  • Wire augmentWikiNodeCreateOutput (+node-create) and +node-copy output/pretty rendering to the helper.

+node-get / +space-create are intentionally untouched — they build their own output maps and deliberately omit URL, so the new struct field does not leak into them.

Test plan

  • go test ./shortcuts/wiki/... passes
  • gofmt clean, go vet ./shortcuts/... clean
  • ./build.sh succeeds
  • Updated existing +node-create e2e test: mock returns a real url; asserts it wins over synthesized fallback
  • Updated existing +node-copy e2e test: mock returns a real url; asserts copy surfaces it
  • Added TestWikiNodeURL covering prefer-response / fallback / blank / nil / no-token
  • golangci-lint not run locally (not installed); relying on CI

Summary by CodeRabbit

  • New Features

    • Wiki node create and copy outputs now include a user-facing URL when available; if the API omits it, a synthesized URL is used as a fallback. The pretty output shows the URL only when present.
  • Tests

    • Tests updated and added to verify URL selection, precedence (API URL preferred), fallback behavior, and output formatting.

Review Change Stack

The create-node and copy-node OpenAPI responses carry a real `url`
field (present in practice though absent from the documented schema).
Both shortcuts ignored it: +node-create synthesized a link via
BuildResourceURL, and +node-copy emitted no URL at all.

Parse `url` into the shared wikiNodeRecord and add a wikiNodeURL helper
that prefers the response url, falling back to BuildResourceURL only
when it is blank. Wire +node-create and +node-copy to the helper so
both surface the canonical link when available.

Change-Id: I0ca5f91b02c24e81d083793e6a8e4f8c966aeec3
@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 May 19, 2026
@coderabbitai

coderabbitai Bot commented May 19, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8df630cb-4aec-47fe-b1d0-065fdd3423a3

📥 Commits

Reviewing files that changed from the base of the PR and between 82e6101 and 13ca095.

📒 Files selected for processing (2)
  • shortcuts/wiki/wiki_helpers.go
  • shortcuts/wiki/wiki_node_create.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • shortcuts/wiki/wiki_node_create.go

📝 Walkthrough

Walkthrough

This PR surfaces server-provided wiki node URLs in create and copy outputs by adding a URL field to node records, introducing wikiNodeURL (prefer response URL, fallback to synthesized URL), and integrating it into create/copy output paths with tests covering resolution and propagation.

Changes

Wiki Node URL Propagation

Layer / File(s) Summary
URL field and resolution helper
shortcuts/wiki/wiki_node_create.go, shortcuts/wiki/wiki_helpers.go, shortcuts/wiki/wiki_node_create_test.go
Adds wikiNodeRecord.URL and a new wikiNodeURL helper that prefers a non-blank node.URL, falls back to common.BuildResourceURL(brand,"wiki", node.NodeToken), and returns "" for nil nodes. Includes table-driven tests TestWikiNodeURL.
Node creation output augmentation
shortcuts/wiki/wiki_node_create.go, shortcuts/wiki/wiki_node_create_test.go
parseWikiNodeRecord reads the server url into wikiNodeRecord.URL. augmentWikiNodeCreateOutput uses wikiNodeURL to set out["url"] only when non-empty. Tests updated to assert response-provided URL is surfaced.
Node copy output augmentation
shortcuts/wiki/wiki_node_copy.go, shortcuts/wiki/wiki_list_copy_test.go
Copy flow calls wikiNodeURL to populate out["url"] when available; pretty renderer prints url only if present. Tests add url to mocked copied-node response and assert propagation to command output.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • larksuite/cli#320: Introduces the wiki +node-create shortcut that this PR extends with URL field handling and output propagation.

Suggested reviewers

  • fangshuyu-768

Poem

🐰 A tiny helper hunts the truth,
Prefers the server's golden booth.
If the API gives a way,
We print that link for users' day.
Otherwise, a fallback play.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% 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 and specifically summarizes the main change: surfacing the real node URL from API responses for both +node-create and +node-copy commands.
Description check ✅ Passed The description is well-structured, covers summary/changes/test plan as per template, and provides comprehensive context about the problem, implementation approach, and verification.
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.

✏️ 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 fix/wiki-node-url

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 and usage tips.

@codecov

codecov Bot commented May 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.03%. Comparing base (c4fb700) to head (13ca095).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #960      +/-   ##
==========================================
+ Coverage   66.93%   67.03%   +0.09%     
==========================================
  Files         568      570       +2     
  Lines       52970    53519     +549     
==========================================
+ Hits        35458    35875     +417     
- Misses      14581    14649      +68     
- Partials     2931     2995      +64     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented May 19, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#fix/wiki-node-url -y -g

@fangshuyu-768 fangshuyu-768 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review Summary

This is a clean, well-scoped fix. The wikiNodeURL helper correctly prioritizes the real API response URL over the synthesized fallback, and the test coverage is solid.

A few suggestions below — none are blocking.

Verdict: LGTM (after confirming the type compatibility question on wiki_node_copy.go).

Comment thread shortcuts/wiki/wiki_node_create.go Outdated
Comment thread shortcuts/wiki/wiki_node_copy.go
Comment thread shortcuts/wiki/wiki_node_create_test.go
The helper is consumed by both +node-create and +node-copy, so its
placement should reflect the broader usage rather than living in the
create command's file. Pure move; no behavior change.

Change-Id: I9990c12da042f631fe2519911c6a9d663fd5c22b
@fangshuyu-768
fangshuyu-768 merged commit 28c66be into main May 19, 2026
21 checks passed
@fangshuyu-768
fangshuyu-768 deleted the fix/wiki-node-url branch May 19, 2026 07:19
@liangshuo-1 liangshuo-1 mentioned this pull request May 19, 2026
2 tasks
tuxedomm pushed a commit to zhumiaoxin/cli that referenced this pull request Jun 6, 2026
…uite#960)

* fix(wiki): surface real node url for +node-create / +node-copy

The create-node and copy-node OpenAPI responses carry a real `url`
field (present in practice though absent from the documented schema).
Both shortcuts ignored it: +node-create synthesized a link via
BuildResourceURL, and +node-copy emitted no URL at all.

Parse `url` into the shared wikiNodeRecord and add a wikiNodeURL helper
that prefers the response url, falling back to BuildResourceURL only
when it is blank. Wire +node-create and +node-copy to the helper so
both surface the canonical link when available.

Change-Id: I0ca5f91b02c24e81d083793e6a8e4f8c966aeec3

* refactor(wiki): move wikiNodeURL to shared wiki_helpers.go

The helper is consumed by both +node-create and +node-copy, so its
placement should reflect the broader usage rather than living in the
create command's file. Pure move; no behavior change.

Change-Id: I9990c12da042f631fe2519911c6a9d663fd5c22b
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