Skip to content

fix(skills): align skill guidance with the typed error contract#1785

Closed
yukunlabs wants to merge 1 commit into
larksuite:mainfrom
yukunlabs:fix/skills-typed-error-contract
Closed

fix(skills): align skill guidance with the typed error contract#1785
yukunlabs wants to merge 1 commit into
larksuite:mainfrom
yukunlabs:fix/skills-typed-error-contract

Conversation

@yukunlabs

@yukunlabs yukunlabs commented Jul 7, 2026

Copy link
Copy Markdown

Summary

Align skill/reference guidance with the current typed error contract so agents do not follow retired raw OpenAPI or legacy envelope shapes. This is a docs-only fix across Lark skill docs and related drive coverage notes.

Changes

  • Updated permission, confirmation, duplicate-remote, and partial-failure guidance to match typed envelopes (missing_scopes, type=confirmation, subtype=confirmation_required, flat risk / action, and stdout ok:false partial results).
  • Replaced raw {code,msg} / backend-response examples in Base and Slides docs with the CLI success/error envelopes that agents actually see.
  • Updated Minutes recovery guidance to branch on stable error.code / error.subtype instead of human message text.
  • Clarified Slides replace failure behavior: typed stderr envelope and exit code, with no raw backend response printed to stdout.

Test Plan

  • Unit tests pass
    • Not run locally: installed Go is 1.20.14 and the module requires Go 1.23.0; this PR changes docs/skill references only.
  • Manual local verification confirms the lark-cli <domain> <command> flow works as expected
    • LARKSUITE_CLI_NO_UPDATE_NOTIFIER=1 LARKSUITE_CLI_NO_SKILLS_NOTIFIER=1 lark-cli drive +delete --file-token file_token_test --type file --as bot exits 10 and emits a typed confirmation envelope with type=confirmation, subtype=confirmation_required, flat risk, and action.
  • git diff --check origin/main...HEAD
  • Added-line scans for retired envelope terms and sensitive material; no problematic additions found.

Related Issues

  • None

Summary by CodeRabbit

  • Documentation

    • Standardized response examples and error guidance across several Lark skills and command references.
    • Updated success responses to use ok and identity fields in examples.
    • Clarified failure handling, including typed validation errors, permission issues, and missing-scope recovery steps.
  • Tests

    • Aligned documented drive coverage expectations with the updated duplicate-remote validation behavior.

Skill references written before the typed-error refactor still taught retired envelope shapes. AI agents following them now read what the CLI actually emits:

- permission recovery reads error.missing_scopes instead of the upstream permission_violations detail
- confirmation gates use type=confirmation, subtype=confirmation_required, and flat risk/action fields
- drive duplicate-remote failures are typed validation envelopes (failed_precondition with params[]), not duplicate_remote_path with error.detail
- drive batch partial failures are ok:false results on stdout, not an error.type=partial_failure stderr envelope
- minutes edit-permission and word-replace misses branch on stable error.code/error.subtype, not message text
- slides replace failures are stderr typed envelopes only; no raw backend response is printed to stdout
- slides and Base command outputs show the ok/identity/data success envelope instead of the raw {code,msg} OpenAPI wrapper
@github-actions github-actions Bot added domain/base PR touches the base domain domain/ccm PR touches the ccm domain size/L Large or sensitive change across domains or core paths labels Jul 7, 2026
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR is a documentation-only update across multiple skill and reference markdown files, aligning error and response field names with a new CLI contract: renaming permission_violations to missing_scopes, replacing code/msg success wrappers with ok/identity, and converting several error types (duplicate_remote_path, no_edit_permission, words_not_found, partial_failure) to typed error.type/error.subtype/error.code fields.

Changes

Response envelope and error field documentation updates

Layer / File(s) Summary
Missing scope field rename
skills/lark-shared/SKILL.md, skills/lark-apps/references/lark-apps-openapi-key.md, skills/lark-base/SKILL.md, skills/lark-vc-agent/SKILL.md, skills/lark-minutes/references/lark-minutes-todo.md
Replaces permission_violations references with missing_scopes in error-handling guidance across shared, base, apps, vc-agent, and minutes docs.
High-risk confirmation envelope update
skills/lark-shared/SKILL.md
Updates exit-10 confirmation error example to error.type=confirmation/subtype=confirmation_required with action/risk fields.
Minutes edit/permission error code updates
skills/lark-minutes/SKILL.md
Switches permission-denied and no-match error checks from error.type to error.code/error.subtype.
Base CLI success/error envelope rewrite
skills/lark-base/references/lark-base-dashboard-block-get-data.md, skills/lark-base/references/lark-base-data-query.md
Replaces code/msg server wrapper documentation with ok/identity CLI success contract and typed error object.
Drive duplicate-remote conflict and failure envelope updates
skills/lark-drive/references/lark-drive-member-add.md, ...-pull.md, ...-push.md, ...-status.md, tests/cli_e2e/drive/coverage.md
Documents ok:false stdout failure envelopes and error.type=validation/subtype=failed_precondition for duplicate rel_path conflicts, replacing prior partial_failure/duplicate_remote_path types.
Slides response examples switch to ok/identity
skills/lark-slides/references/*.md
Updates JSON examples across slides commands from code/msg to ok/identity, and rewrites the slide-replace failure section to a typed error envelope.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

  • larksuite/cli#505: Both PRs update skills/lark-base/SKILL.md's permission-error recovery logic to use missing_scopes/hint instead of permission_violations/hint.
  • larksuite/cli#1598: Both PRs update skills/lark-shared/SKILL.md's missing-scope error field guidance from permission_violations to missing_scopes.
  • larksuite/cli#1730: Both PRs align skill reference examples' success JSON from code/msg to ok/identity.

Suggested labels: documentation

Suggested reviewers: liangshuo-1, fangshuyu-768, zhaoleibd, SunPeiYang996

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the docs-only change to align skill guidance with the typed error contract.
Description check ✅ Passed The description follows the template with Summary, Changes, Test Plan, and Related Issues sections filled in.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

@evandance

Copy link
Copy Markdown
Collaborator

Closing this PR because it was opened from the wrong GitHub identity. Recreating it from the evandance-owned branch.

@evandance evandance closed this Jul 7, 2026

@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: 2

🤖 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 `@skills/lark-base/references/lark-base-data-query.md`:
- Around line 350-371: The CLI response section documents `error.code`,
`error.message`, and `error.hint`, but it omits the stable branching fields
already shown in the failure example. Update the Response 字段 table in
`lark-base-data-query.md` to include `error.type` and `error.subtype`, and make
it clear in the CLI 出参详情 around the success/failure examples that these typed
discriminators should be used alongside `error.code` when handling errors.

In `@skills/lark-slides/references/lark-slides-xml-presentation-slide-replace.md`:
- Around line 159-164: The failure envelope documentation is incomplete because
the example includes error.type and error.message but the field table in the
slide replace doc only lists error.code, error.subtype, and error.hint. Update
the table in the same section to add rows for error.type and error.message so
the stderr contract described by the slide-replace example is fully documented
and self-contained.
🪄 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: 1faa0078-5173-4a04-a4c2-be1d4ec70029

📥 Commits

Reviewing files that changed from the base of the PR and between 6f95c5e and e20db5a.

📒 Files selected for processing (20)
  • skills/lark-apps/references/lark-apps-openapi-key.md
  • skills/lark-base/SKILL.md
  • skills/lark-base/references/lark-base-dashboard-block-get-data.md
  • skills/lark-base/references/lark-base-data-query.md
  • skills/lark-drive/references/lark-drive-member-add.md
  • skills/lark-drive/references/lark-drive-pull.md
  • skills/lark-drive/references/lark-drive-push.md
  • skills/lark-drive/references/lark-drive-status.md
  • skills/lark-minutes/SKILL.md
  • skills/lark-minutes/references/lark-minutes-todo.md
  • skills/lark-shared/SKILL.md
  • skills/lark-slides/references/examples.md
  • skills/lark-slides/references/lark-slides-screenshot.md
  • skills/lark-slides/references/lark-slides-xml-presentation-slide-create.md
  • skills/lark-slides/references/lark-slides-xml-presentation-slide-delete.md
  • skills/lark-slides/references/lark-slides-xml-presentation-slide-get.md
  • skills/lark-slides/references/lark-slides-xml-presentation-slide-replace.md
  • skills/lark-slides/references/lark-slides-xml-presentations-get.md
  • skills/lark-vc-agent/SKILL.md
  • tests/cli_e2e/drive/coverage.md

Comment on lines +350 to +371
## CLI 出参详情

**成功时:**
**成功时**(stdout,判断成功用 `ok == true` 或退出码 0):

```json
{"code": 0, "data": {"main_data": [{"dim_city": {"value": "北京"}, "total_amount": {"value": 12345.00}}, ...]}, "msg": ""}
{"ok": true, "identity": "user", "data": {"main_data": [{"dim_city": {"value": "北京"}, "total_amount": {"value": 12345.00}}, ...]}}
```

**失败时:**
**失败时**(stderr 类型化错误信封,非零退出码;`error.code` 是上游 API 错误码):

```json
{"code": 800004006, "data": {"error": {"code": 800004006, ...}}, "msg": "DSL validation failed"}
{"ok": false, "identity": "user", "error": {"type": "api", "subtype": "...", "code": 800004006, "message": "DSL validation failed", "hint": "..."}}
```

**Response 字段:**

| 字段 | 类型 | 说明 |
|------|------|------|
| `code` | int | 状态码,0 为成功 |
| `msg` | string | 错误信息 |
| `ok` | bool | 是否成功 |
| `data.main_data` | []object | 查询结果数组,每个元素为一行数据 |
| `data.error` | object | 失败时的错误详情 |
| `error.code` | int | 失败时的上游 API 错误码 |
| `error.message` / `error.hint` | string | 失败原因与建议的恢复动作 |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Document the stable error discriminators too.

The example already relies on error.type / error.subtype, but the table only explains error.code and the message fields. Please add the typed discriminator rows so readers don’t treat code as the only branching key.

♻️ Suggested table update
 | 字段 | 类型 | 说明 |
 |------|------|------|
 | `ok` | bool | 是否成功 |
 | `data.main_data` | []object | 查询结果数组,每个元素为一行数据 |
+| `error.type` | string | 错误大类 |
+| `error.subtype` | string | 细分错误类型 |
 | `error.code` | int | 失败时的上游 API 错误码 |
 | `error.message` / `error.hint` | string | 失败原因与建议的恢复动作 |
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## CLI 出参详情
**成功时:**
**成功时**(stdout,判断成功用 `ok == true` 或退出码 0):
```json
{"code": 0, "data": {"main_data": [{"dim_city": {"value": "北京"}, "total_amount": {"value": 12345.00}}, ...]}, "msg": ""}
{"ok": true, "identity": "user", "data": {"main_data": [{"dim_city": {"value": "北京"}, "total_amount": {"value": 12345.00}}, ...]}}
```
**失败时:**
**失败时**(stderr 类型化错误信封,非零退出码;`error.code` 是上游 API 错误码):
```json
{"code": 800004006, "data": {"error": {"code": 800004006, ...}}, "msg": "DSL validation failed"}
{"ok": false, "identity": "user", "error": {"type": "api", "subtype": "...", "code": 800004006, "message": "DSL validation failed", "hint": "..."}}
```
**Response 字段:**
| 字段 | 类型 | 说明 |
|------|------|------|
| `code` | int | 状态码,0 为成功 |
| `msg` | string | 错误信息 |
| `ok` | bool | 是否成功 |
| `data.main_data` | []object | 查询结果数组,每个元素为一行数据 |
| `data.error` | object | 失败时的错误详情 |
| `error.code` | int | 失败时的上游 API 错误码 |
| `error.message` / `error.hint` | string | 失败原因与建议的恢复动作 |
## CLI 出参详情
**成功时**(stdout,判断成功用 `ok == true` 或退出码 0):
🤖 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 `@skills/lark-base/references/lark-base-data-query.md` around lines 350 - 371,
The CLI response section documents `error.code`, `error.message`, and
`error.hint`, but it omits the stable branching fields already shown in the
failure example. Update the Response 字段 table in `lark-base-data-query.md` to
include `error.type` and `error.subtype`, and make it clear in the CLI 出参详情
around the success/failure examples that these typed discriminators should be
used alongside `error.code` when handling errors.

Comment on lines 159 to +164
| 字段 | 类型 | 说明 |
|------|------|------|
| `data.revision_id` | integer | 成功时返回更新后最新版本号 |
| `data.failed_part_index` | integer | 失败的 part 在 `parts` 数组中的索引(从 0 起) |
| `data.failed_reason` | string | 失败原因 |
| `error.code` | integer | 失败时的上游 API 错误码 |
| `error.subtype` | string | 类型化错误子类,脚本可与 `error.code` 一起判断恢复动作 |
| `error.hint` | string | 建议的恢复动作 |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Document the full failure envelope.

The new example exposes error.type and error.message, but the field table only covers error.code, error.subtype, and error.hint. Please add the missing rows so the typed stderr contract is self-contained for scripts and agents.

Proposed fix
 | `data.revision_id` | integer | 成功时返回更新后最新版本号 |
+| `error.type` | string | 失败时的错误类型 |
+| `error.message` | string | 失败原因说明 |
 | `error.code` | integer | 失败时的上游 API 错误码 |
 | `error.subtype` | string | 类型化错误子类,脚本可与 `error.code` 一起判断恢复动作 |
 | `error.hint` | string | 建议的恢复动作 |
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
| 字段 | 类型 | 说明 |
|------|------|------|
| `data.revision_id` | integer | 成功时返回更新后最新版本号 |
| `data.failed_part_index` | integer | 失败的 part 在 `parts` 数组中的索引(从 0 起) |
| `data.failed_reason` | string | 失败原因 |
| `error.code` | integer | 失败时的上游 API 错误码 |
| `error.subtype` | string | 类型化错误子类,脚本可与 `error.code` 一起判断恢复动作 |
| `error.hint` | string | 建议的恢复动作 |
| 字段 | 类型 | 说明 |
|------|------|------|
| `data.revision_id` | integer | 成功时返回更新后最新版本号 |
| `error.type` | string | 失败时的错误类型 |
| `error.message` | string | 失败原因说明 |
| `error.code` | integer | 失败时的上游 API 错误码 |
| `error.subtype` | string | 类型化错误子类,脚本可与 `error.code` 一起判断恢复动作 |
| `error.hint` | string | 建议的恢复动作 |
🤖 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 `@skills/lark-slides/references/lark-slides-xml-presentation-slide-replace.md`
around lines 159 - 164, The failure envelope documentation is incomplete because
the example includes error.type and error.message but the field table in the
slide replace doc only lists error.code, error.subtype, and error.hint. Update
the table in the same section to add rows for error.type and error.message so
the stderr contract described by the slide-replace example is fully documented
and self-contained.

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 domain/ccm PR touches the ccm domain size/L Large or sensitive change across domains or core paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants