Skip to content

chore(doc): inject docs scene into v2 requests#808

Merged
SunPeiYang996 merged 1 commit into
mainfrom
sun/chore
May 11, 2026
Merged

chore(doc): inject docs scene into v2 requests#808
SunPeiYang996 merged 1 commit into
mainfrom
sun/chore

Conversation

@SunPeiYang996
Copy link
Copy Markdown
Collaborator

@SunPeiYang996 SunPeiYang996 commented May 11, 2026

Change-Id: I4f23880e24164c8b229a5403942bfa1b7ddb0ce6

Changes

inject docs scene into v2 requests

Summary by CodeRabbit

  • New Features

    • Document create, fetch, and update requests now include an optional "scene" field pulled from context (whitespace trimmed) when provided.
  • Tests

    • Added unit tests verifying the "scene" field is included when present, trimmed of surrounding whitespace, and omitted when empty across document operations.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3582a45e-6cf4-464d-8594-d3550002d659

📥 Commits

Reviewing files that changed from the base of the PR and between 0fdcba5 and 0922bff.

📒 Files selected for processing (5)
  • shortcuts/doc/docs_create_v2.go
  • shortcuts/doc/docs_fetch_v2.go
  • shortcuts/doc/docs_fetch_v2_test.go
  • shortcuts/doc/docs_update_v2.go
  • shortcuts/doc/helpers.go
🚧 Files skipped from review as they are similar to previous changes (5)
  • shortcuts/doc/docs_update_v2.go
  • shortcuts/doc/docs_create_v2.go
  • shortcuts/doc/docs_fetch_v2.go
  • shortcuts/doc/helpers.go
  • shortcuts/doc/docs_fetch_v2_test.go

📝 Walkthrough

Walkthrough

Extract a server-owned "docs scene" string from runtime context and conditionally inject it into fetch, create, and update OpenAPI request bodies; new helpers implement extraction/injection and tests validate trimmed inclusion or omission.

Changes

Docs Scene Context Injection

Layer / File(s) Summary
Helper Mechanism
shortcuts/doc/helpers.go
Import context, define internal docsSceneContextKey, add docsSceneFromContext() to safely extract and trim a scene string, and add injectDocsScene() to set body["scene"] when non-empty.
API Operation Integration
shortcuts/doc/docs_create_v2.go, shortcuts/doc/docs_fetch_v2.go, shortcuts/doc/docs_update_v2.go
buildCreateBody, buildFetchBody, and buildUpdateBody each call injectDocsScene(runtime, body) before returning to extend their request payloads with scene metadata.
Test Coverage
shortcuts/doc/docs_fetch_v2_test.go
New parallelized tests confirm fetch/create/update builders include a trimmed "scene" from context or omit it when absent; includes helpers to construct minimal common.RuntimeContext instances for each operation.

Sequence Diagram(s)

sequenceDiagram
  participant buildCreateBody
  participant buildFetchBody
  participant buildUpdateBody
  participant injectDocsScene
  participant docsSceneFromContext
  participant runtimeCtx
  participant bodyMap

  buildCreateBody->>injectDocsScene: injectDocsScene(runtime, body)
  buildFetchBody->>injectDocsScene: injectDocsScene(runtime, body)
  buildUpdateBody->>injectDocsScene: injectDocsScene(runtime, body)
  injectDocsScene->>docsSceneFromContext: docsSceneFromContext(runtime.Ctx())
  docsSceneFromContext->>runtimeCtx: read docsSceneContextKey
  runtimeCtx-->>docsSceneFromContext: scene string (maybe empty)
  docsSceneFromContext-->>injectDocsScene: trimmed scene
  injectDocsScene->>bodyMap: set body["scene"] if non-empty
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • evandance

Poem

🐰 I sniffed a scene within the code,
Trimmed the edges down the road,
Three builders learned the secret word,
Tests hopped in to make it heard,
Payloads now carry that small ode.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete compared to the template; it lacks Summary, Test Plan, and Related Issues sections required for a comprehensive PR description. Expand the description to include: a brief motivation/scope summary (1-3 sentences), explicit test plan with test execution status, and a Related Issues section (even if 'None').
Docstring Coverage ⚠️ Warning Docstring coverage is 7.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: injecting docs scene into v2 API requests across the codebase.
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 sun/chore

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

@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 11, 2026
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.

🧹 Nitpick comments (2)
shortcuts/doc/docs_fetch_v2_test.go (1)

61-95: ⚡ Quick win

Use the standard unit-test factory pattern here.

The runtime setup helpers on Lines 61-95 should use cmdutil.TestFactory(t, config) to stay consistent with the repo’s unit-test harness conventions.

As per coding guidelines **/*_test.go: Use cmdutil.TestFactory(t, config) for test factories in unit tests.

🤖 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/doc/docs_fetch_v2_test.go` around lines 61 - 95, The three test
helper functions newFetchBodyTestRuntime, newCreateBodyTestRuntime, and
newUpdateBodyTestRuntime must be converted to use the repo test-factory pattern:
change their signature to accept *testing.T, build a factory with
cmdutil.TestFactory(t, config) (where config sets the command and flags
currently created in each helper), and use that factory to produce the
RuntimeContext instead of calling common.TestNewRuntimeContextWithCtx; update
callers in tests accordingly so they pass t and rely on the factory-created
runtime.
shortcuts/doc/helpers.go (1)

15-18: ⚡ Quick win

Use a typed context key instead of a string constant.

Line 17 defines docsSceneContextKey as a plain string, which is non-idiomatic for Go contexts and risks key collisions. Use a private typed constant instead.

🔧 Proposed patch
-const docsSceneContextKey = "lark_cli_docs_scene"
+type docsSceneContextKeyType string
+
+const docsSceneContextKey docsSceneContextKeyType = "lark_cli_docs_scene"

Also applies to: 73-79

🤖 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/doc/helpers.go` around lines 15 - 18, Replace the untyped string
context key docsSceneContextKey with a private typed key to avoid collisions:
define a new unexported type (e.g., type contextKey string) and a package-level
const/var of that type (e.g., var docsSceneContextKey =
contextKey("lark_cli_docs_scene")), then update all uses (including the places
around the other occurrence at lines ~73-79) to use that typed key when
setting/getting values from context; ensure the key remains unexported so only
this package can use it.
🤖 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.

Nitpick comments:
In `@shortcuts/doc/docs_fetch_v2_test.go`:
- Around line 61-95: The three test helper functions newFetchBodyTestRuntime,
newCreateBodyTestRuntime, and newUpdateBodyTestRuntime must be converted to use
the repo test-factory pattern: change their signature to accept *testing.T,
build a factory with cmdutil.TestFactory(t, config) (where config sets the
command and flags currently created in each helper), and use that factory to
produce the RuntimeContext instead of calling
common.TestNewRuntimeContextWithCtx; update callers in tests accordingly so they
pass t and rely on the factory-created runtime.

In `@shortcuts/doc/helpers.go`:
- Around line 15-18: Replace the untyped string context key docsSceneContextKey
with a private typed key to avoid collisions: define a new unexported type
(e.g., type contextKey string) and a package-level const/var of that type (e.g.,
var docsSceneContextKey = contextKey("lark_cli_docs_scene")), then update all
uses (including the places around the other occurrence at lines ~73-79) to use
that typed key when setting/getting values from context; ensure the key remains
unexported so only this package can use it.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dd14627f-8975-4741-937e-03fb796fbd43

📥 Commits

Reviewing files that changed from the base of the PR and between 16f1a0f and 463c1f6.

📒 Files selected for processing (5)
  • shortcuts/doc/docs_create_v2.go
  • shortcuts/doc/docs_fetch_v2.go
  • shortcuts/doc/docs_fetch_v2_test.go
  • shortcuts/doc/docs_update_v2.go
  • shortcuts/doc/helpers.go

@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

❌ Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.67%. Comparing base (5352e6a) to head (0922bff).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
shortcuts/doc/helpers.go 75.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #808      +/-   ##
==========================================
+ Coverage   65.60%   65.67%   +0.06%     
==========================================
  Files         513      513              
  Lines       47644    47655      +11     
==========================================
+ Hits        31259    31297      +38     
+ Misses      13685    13652      -33     
- Partials     2700     2706       +6     

☔ 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
Copy link
Copy Markdown

github-actions Bot commented May 11, 2026

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#sun/chore -y -g

Change-Id: I4f23880e24164c8b229a5403942bfa1b7ddb0ce6
@SunPeiYang996 SunPeiYang996 merged commit 0ed63b0 into main May 11, 2026
20 checks passed
@SunPeiYang996 SunPeiYang996 deleted the sun/chore branch May 11, 2026 06:35
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