Skip to content

feat(wiki): emit typed error envelopes across the wiki domain#1350

Merged
evandance merged 1 commit into
mainfrom
feat/errs-migrate-wiki
Jun 11, 2026
Merged

feat(wiki): emit typed error envelopes across the wiki domain#1350
evandance merged 1 commit into
mainfrom
feat/errs-migrate-wiki

Conversation

@evandance

@evandance evandance commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Migrates typed error envelopes across the Wiki shortcut domain. Scope is limited to shortcuts/wiki, Wiki error-contract guards, and Wiki guard tests.

Changes

  • Converts Wiki space, node, member, move/copy/delete/list, async task, API, network, and invalid-response failures to typed errs.* envelopes.
  • Attaches structured invalid-param diagnostics to validation failures, including multi-flag combination checks (mutual-exclusion and at-least-one), and keeps async task failures actionable with typed problem propagation.
  • Adds Wiki coverage to .golangci.yml and lint/errscontract so legacy envelopes and common helpers cannot regress.

Test Plan

  • gofmt -l <changed go files> produced no output
  • go vet ./shortcuts/wiki/...
  • go test ./shortcuts/wiki/...
  • go test -C lint ./...
  • go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6 run --new-from-rev=origin/main
  • go run -C lint . ..
  • go build ./...

Related Issues

  • None

Summary by CodeRabbit

  • Bug Fixes

    • Unified typed error handling across wiki commands — preserves original error codes, improves/preserves resume & retry hints, and attaches validation failures to specific flags for clearer guidance.
  • Chores / Refactor

    • Wiki shortcuts switched to typed API calls and the errs error framework for consistent classification and hint propagation.
  • Tests

    • Linter rules/tests extended to cover wiki paths and new typed-error shapes; added tests for aliasing, function-value usage, and validation param assertions.

@evandance evandance added size/M Single-domain feat or fix with limited business impact domain/ccm PR touches the ccm domain feature labels Jun 9, 2026
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Migrate shortcuts/wiki to typed errs: update lint exceptions, switch runtime.CallAPI -> CallAPITyped, convert validation/internal/API errors to errs.New* with parameter binding, refactor polling/retry hint propagation to use errs.ProblemOf, and update tests to assert typed problems and validation parameter hints.

Changes

Wiki Shortcuts Typed-Error Migration

Layer / File(s) Summary
Lint infra & wiki path tests
.golangci.yml, lint/errscontract/rule_no_legacy_common_helper_call.go, lint/errscontract/rule_no_legacy_envelope_literal.go, lint/errscontract/rules_test.go
Add shortcuts/wiki/ to forbidigo path-except and migrated-path lists; tests add wiki-path legacy-helper cases including alias/function-value shapes.
Async task polling & resume-hint propagation
shortcuts/wiki/wiki_async_task.go, shortcuts/wiki/wiki_async_task_test.go
Switch async polling to typed errs.NewInternalError / errs.NewAPIError; use errs.ProblemOf to preserve/append resume hints instead of reconstructing output.ExitError; tests validate via errs.ProblemOf.
Delete-space API & validation
shortcuts/wiki/wiki_delete.go, shortcuts/wiki/wiki_delete_test.go
Use runtime.CallAPITyped for DeleteSpace/GetDeleteSpaceTask; change missing --space-id validation to errs.NewValidationError(...).WithParam("--space-id"); tests seed/assert typed API errors via errclass/errs.ProblemOf.
Member & space CRUD (validation + typed API)
shortcuts/wiki/wiki_member_add.go, shortcuts/wiki/wiki_member_remove.go, shortcuts/wiki/wiki_member_helpers.go, shortcuts/wiki/wiki_member_list.go, shortcuts/wiki/wiki_space_create.go, shortcuts/wiki/wiki_space_list.go
Replace output.ErrValidation with errs.NewValidationError(...).WithParam(...); migrate API calls to CallAPITyped and add errs imports.
Node get: token/URL/obj-type validation
shortcuts/wiki/wiki_node_get.go
Switch GET to CallAPITyped; refactor validations for --space-id, --node-token, --obj-type, and URL parsing to errs.NewValidationError(...).WithParam(...).
Node list & copy
shortcuts/wiki/wiki_node_list.go, shortcuts/wiki/wiki_node_copy.go
Switch pagination and node-copy calls to CallAPITyped; update bot-context and target-flag validations to typed errs.NewValidationError(...).WithParams(...).
Node create: lock-contention retry & hint mutation
shortcuts/wiki/wiki_node_create.go, shortcuts/wiki/wiki_node_create_test.go
CallAPITyped for GetNode/GetSpace/CreateNode; detect lock contention via errs.ProblemOf and mutate p.Hint in-place on retry exhaustion; tests add typed lock-contention error builder and structured param assertions.
Node delete: API error wrapping & hint mapping
shortcuts/wiki/wiki_node_delete.go, shortcuts/wiki/wiki_node_delete_test.go
CallAPITyped for delete-related APIs; refactor validations to errs.NewValidationError(...).WithParam(...); wrapWikiNodeDeleteAPIError inspects errs.ProblemOf and appends hints in-place; tests updated to use errclass/errs.ProblemOf.
Wiki move: multi-mode flow & polling
shortcuts/wiki/wiki_move.go, shortcuts/wiki/wiki_move_test.go
All wiki-move API calls -> CallAPITyped; validations -> errs.NewValidationError(...).WithParam/WithParams; unexpected responses -> errs.NewInternalError; polling failures -> errs.NewAPIError and hint mutation via errs.ProblemOf; tests seed/assert typed errors and parameter hints.
Test updates: assertions & helpers
shortcuts/wiki/*_test.go, lint/errscontract/rules_test.go
Add helpers to build typed API errors and assert validation parameter hints; replace output.ExitError assertions with errs.ProblemOf-based checks; expand migrated-path rule tests for wiki shapes.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • larksuite/cli#1242: Extends the no_legacy_common_helper_call errscontract rule and migrated-path enforcement (closely related lint changes).
  • larksuite/cli#1346: Similar errscontract/.golangci.yml migration work expanding migrated-path lists for other shortcuts.
  • larksuite/cli#1076: Related node-create retry/lock-contention changes and retry logic overlap.

Suggested reviewers

  • zhaoleibd
  • wittam-01

"🐰
I hopped through wiki code today,
ExitErrors folded, errs lead the way.
Calls are typed and hints tuck in tight,
Flags now carry params just right.
A little rabbit cheers the tidy sight."

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% 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 PR title clearly and specifically summarizes the main change: migrating typed error envelopes across the wiki domain, which is the primary objective of this changeset.
Description check ✅ Passed The PR description follows the template with all required sections completed: Summary clearly states the migration scope, Changes lists specific modifications, Test Plan includes verified testing steps with checkmarks, and Related Issues is addressed.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/errs-migrate-wiki

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 size/L Large or sensitive change across domains or core paths and removed size/M Single-domain feat or fix with limited business impact labels Jun 9, 2026
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#feat/errs-migrate-wiki -y -g

@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.91946% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.98%. Comparing base (8e667db) to head (c2ca5d8).

Files with missing lines Patch % Lines
shortcuts/wiki/wiki_node_create.go 76.47% 6 Missing and 2 partials ⚠️
shortcuts/wiki/wiki_node_delete.go 80.95% 3 Missing and 1 partial ⚠️
shortcuts/wiki/wiki_move.go 92.10% 3 Missing ⚠️
shortcuts/wiki/wiki_member_add.go 75.00% 1 Missing ⚠️
shortcuts/wiki/wiki_member_helpers.go 50.00% 1 Missing ⚠️
shortcuts/wiki/wiki_node_get.go 94.11% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1350   +/-   ##
=======================================
  Coverage   71.98%   71.98%           
=======================================
  Files         700      700           
  Lines       66293    66294    +1     
=======================================
+ Hits        47721    47724    +3     
  Misses      14867    14867           
+ Partials     3705     3703    -2     

☔ View full report in Codecov by Harness.
📢 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.

@evandance evandance force-pushed the feat/errs-migrate-wiki branch from 26172ff to a98a591 Compare June 9, 2026 07:59

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
shortcuts/wiki/wiki_node_list.go (1)

154-175: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Return a typed invalid-response error when pagination fields are malformed.

At Lines 158-165, the unchecked assertions fall back to zero values, so a code=0 response with a bad items, has_more, or page_token shape can be rendered as an empty/truncated list instead of surfacing the contract break. That leaves this wiki list path outside the typed invalid-response migration this PR is doing.

🤖 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/wiki/wiki_node_list.go` around lines 154 - 175, The code currently
ignores type-assertion failures for data["items"], data["has_more"], and
data["page_token"], silently using zero values; update the loop in the function
that calls runtime.CallAPITyped to validate those fields' types and on any
mismatch return a typed "invalid-response" error instead of continuing (i.e.,
check that data["items"] is []interface{} and each item is
map[string]interface{} before calling wikiNodeListItem, and ensure
data["has_more"] is bool and data["page_token"] is string); use the same error
shape used elsewhere in the repo for malformed API responses so callers receive
a clear contract-break error rather than an empty/truncated result.
shortcuts/wiki/wiki_node_delete.go (1)

145-158: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Validate the delete response before interpreting task_id as sync completion.

common.GetString(data, "task_id") collapses any non-string task_id to "", and runWikiNodeDelete treats "" as a completed synchronous delete at Line 331. A malformed success payload would therefore be reported as finished instead of surfaced as a typed invalid-response error. Please branch on an explicitly validated response shape here.

🤖 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/wiki/wiki_node_delete.go` around lines 145 - 158, The code
currently treats any non-string or missing "task_id" as "" by using
common.GetString(data, "task_id"), which makes runWikiNodeDelete treat malformed
success payloads as a completed sync delete; instead, after the CallAPITyped
call in the same function (the block that calls wrapWikiNodeDeleteAPIError on
err), explicitly validate that the response contains a "task_id" field of type
string and non-empty (inspect data["task_id"] or use a typed accessor and an
ok/type check) and if it is missing or not a string return a typed
invalid-response error (do not return ""), otherwise return the validated
task_id; reference the callers runWikiNodeDelete and the helper
wrapWikiNodeDeleteAPIError/common.GetString to locate the change.
🤖 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.

Outside diff comments:
In `@shortcuts/wiki/wiki_node_delete.go`:
- Around line 145-158: The code currently treats any non-string or missing
"task_id" as "" by using common.GetString(data, "task_id"), which makes
runWikiNodeDelete treat malformed success payloads as a completed sync delete;
instead, after the CallAPITyped call in the same function (the block that calls
wrapWikiNodeDeleteAPIError on err), explicitly validate that the response
contains a "task_id" field of type string and non-empty (inspect data["task_id"]
or use a typed accessor and an ok/type check) and if it is missing or not a
string return a typed invalid-response error (do not return ""), otherwise
return the validated task_id; reference the callers runWikiNodeDelete and the
helper wrapWikiNodeDeleteAPIError/common.GetString to locate the change.

In `@shortcuts/wiki/wiki_node_list.go`:
- Around line 154-175: The code currently ignores type-assertion failures for
data["items"], data["has_more"], and data["page_token"], silently using zero
values; update the loop in the function that calls runtime.CallAPITyped to
validate those fields' types and on any mismatch return a typed
"invalid-response" error instead of continuing (i.e., check that data["items"]
is []interface{} and each item is map[string]interface{} before calling
wikiNodeListItem, and ensure data["has_more"] is bool and data["page_token"] is
string); use the same error shape used elsewhere in the repo for malformed API
responses so callers receive a clear contract-break error rather than an
empty/truncated result.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b06ba0e8-0b4e-4d85-bf51-a18af0e44764

📥 Commits

Reviewing files that changed from the base of the PR and between 26172ff and a98a591.

📒 Files selected for processing (23)
  • .golangci.yml
  • lint/errscontract/rule_no_legacy_common_helper_call.go
  • lint/errscontract/rule_no_legacy_envelope_literal.go
  • lint/errscontract/rules_test.go
  • shortcuts/wiki/wiki_async_task.go
  • shortcuts/wiki/wiki_async_task_test.go
  • shortcuts/wiki/wiki_delete.go
  • shortcuts/wiki/wiki_delete_test.go
  • shortcuts/wiki/wiki_member_add.go
  • shortcuts/wiki/wiki_member_helpers.go
  • shortcuts/wiki/wiki_member_list.go
  • shortcuts/wiki/wiki_member_remove.go
  • shortcuts/wiki/wiki_move.go
  • shortcuts/wiki/wiki_move_test.go
  • shortcuts/wiki/wiki_node_copy.go
  • shortcuts/wiki/wiki_node_create.go
  • shortcuts/wiki/wiki_node_create_test.go
  • shortcuts/wiki/wiki_node_delete.go
  • shortcuts/wiki/wiki_node_delete_test.go
  • shortcuts/wiki/wiki_node_get.go
  • shortcuts/wiki/wiki_node_list.go
  • shortcuts/wiki/wiki_space_create.go
  • shortcuts/wiki/wiki_space_list.go
✅ Files skipped from review due to trivial changes (1)
  • lint/errscontract/rule_no_legacy_common_helper_call.go
🚧 Files skipped from review as they are similar to previous changes (19)
  • shortcuts/wiki/wiki_member_list.go
  • shortcuts/wiki/wiki_member_helpers.go
  • lint/errscontract/rule_no_legacy_envelope_literal.go
  • shortcuts/wiki/wiki_delete.go
  • shortcuts/wiki/wiki_delete_test.go
  • shortcuts/wiki/wiki_async_task.go
  • shortcuts/wiki/wiki_node_delete_test.go
  • shortcuts/wiki/wiki_async_task_test.go
  • lint/errscontract/rules_test.go
  • shortcuts/wiki/wiki_space_list.go
  • shortcuts/wiki/wiki_member_add.go
  • shortcuts/wiki/wiki_space_create.go
  • shortcuts/wiki/wiki_member_remove.go
  • shortcuts/wiki/wiki_node_create_test.go
  • shortcuts/wiki/wiki_move_test.go
  • shortcuts/wiki/wiki_node_create.go
  • shortcuts/wiki/wiki_move.go
  • shortcuts/wiki/wiki_node_copy.go
  • shortcuts/wiki/wiki_node_get.go

@evandance evandance force-pushed the feat/errs-migrate-wiki branch from a98a591 to 25a69d7 Compare June 9, 2026 12:27

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
shortcuts/wiki/wiki_move_test.go (1)

207-225: ⚠️ Potential issue | 🟠 Major | ⚖️ Poor tradeoff

Incomplete test coverage for typed error params.

The test cases on lines 207-225 validate error messages but don't assert the structured validation parameters, even though the production code (context snippet 1, lines 334, 350, 353, 356) sets .WithParam() for these error paths:

  • Line 207: Should assert wantParams: []string{"--source-space-id"}
  • Line 212: Should assert wantParams: []string{"--obj-type"}
  • Line 217: Should assert wantParams: []string{"--obj-token"}
  • Line 222: Should assert wantParams: []string{"--target-space-id"}

As per coding guidelines, error-path tests must assert typed metadata (category/subtype/param) via errs.ProblemOf, not message substrings alone.

📋 Proposed fix to add missing param assertions
 	{
 		name:    "source space requires node token",
 		spec:    wikiMoveSpec{SourceSpaceID: "space_src", ObjType: "sheet", ObjToken: "sheet_token", TargetSpaceID: "space_dst"},
 		wantErr: "can only be used with --node-token",
+		wantParams: []string{"--source-space-id"},
 	},
 	{
 		name:    "docs to wiki requires obj type",
 		spec:    wikiMoveSpec{ObjToken: "sheet_token", TargetSpaceID: "space_dst"},
 		wantErr: "--obj-type is required",
+		wantParams: []string{"--obj-type"},
 	},
 	{
 		name:    "docs to wiki requires obj token",
 		spec:    wikiMoveSpec{ObjType: "sheet", TargetSpaceID: "space_dst"},
 		wantErr: "--obj-token is required",
+		wantParams: []string{"--obj-token"},
 	},
 	{
 		name:    "docs to wiki requires target space",
 		spec:    wikiMoveSpec{ObjType: "sheet", ObjToken: "sheet_token"},
 		wantErr: "--target-space-id is required",
+		wantParams: []string{"--target-space-id"},
 	},
🤖 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/wiki/wiki_move_test.go` around lines 207 - 225, The test cases in
wiki_move_test.go that check validation errors need to also assert the
structured error params set by the production code; update the four cases with
names "source space requires node token", "docs to wiki requires obj type",
"docs to wiki requires obj token", and "docs to wiki requires target space" by
adding wantParams fields respectively: []string{"--source-space-id"},
[]string{"--obj-type"}, []string{"--obj-token"}, and
[]string{"--target-space-id"} and change the verification to use errs.ProblemOf
(or the existing helper that invokes errs.ProblemOf) to assert the Problem
params match wantParams instead of only checking the error string.

Source: Coding guidelines

🧹 Nitpick comments (1)
shortcuts/wiki/wiki_node_create_test.go (1)

132-150: ⚡ Quick win

Make the shared validation helper lock the typed contract, not just param names.

Lines 132-150 only prove err is a *errs.ValidationError and that Params contains the expected flags. The migrated callers still need message substrings to distinguish whether they got the right typed failure. Fold an errs.ProblemOf(err) assertion for CategoryValidation / SubtypeInvalidArgument into this helper so the touched validation tests can stop keying on prose.

As per coding guidelines, *_test.go error-path tests must assert typed metadata via errs.ProblemOf rather than message substrings alone.

🤖 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/wiki/wiki_node_create_test.go` around lines 132 - 150, The helper
requireWikiValidationParams should also assert the typed problem metadata
instead of relying on message substrings: after confirming err is a
*errs.ValidationError, call errs.ProblemOf(err) and verify problem.Category ==
errs.CategoryValidation and problem.Subtype == errs.SubtypeInvalidArgument,
failing the test with t.Fatalf if either check is false; keep the existing
Params name checks (use the existing ve.Params loop) so callers no longer need
to inspect error prose.

Source: Coding guidelines

🤖 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/wiki/wiki_move_test.go`:
- Around line 236-239: The test currently calls requireWikiValidationParams(t,
err, ...) which only asserts err is a *errs.ValidationError and checks
ve.Params; update the test to also assert typed metadata
(category/subtype/param) expectations: either extend requireWikiValidationParams
(defined in wiki_node_create_test.go) to accept and assert
errs.ProblemOf(category, subtype, param) and preserve error cause, or add
explicit assertions in wiki_move_test.go after the helper call that cast err to
*errs.ValidationError, check errs.ProblemOf(...) matches the error metadata and
that the original cause is preserved; reference the helper
requireWikiValidationParams, the *errs.ValidationError type, ve.Params, and
errs.ProblemOf when adding these checks.

In `@shortcuts/wiki/wiki_node_create.go`:
- Around line 484-488: The current requireWikiSpaceID function treats a missing
space.SpaceID as SubtypeInvalidArgument and suggests the caller change flags;
instead classify this as an invalid-response/internal error since GetSpace and
parseWikiSpaceRecord already validated caller input. Change the error
construction in requireWikiSpaceID to use the internal/invalid-response subtype
(e.g., errs.SubtypeInvalidResponse or errs.NewInternalError) rather than
errs.SubtypeInvalidArgument, and if you still want to surface the "--space-id"
escape hatch put it in a non-primary hint (e.g., .WithHint or similar) rather
than as the primary parameter; keep references to GetSpace and
parseWikiSpaceRecord in the comment/logic to indicate this is a
server/malformed-response issue.

---

Outside diff comments:
In `@shortcuts/wiki/wiki_move_test.go`:
- Around line 207-225: The test cases in wiki_move_test.go that check validation
errors need to also assert the structured error params set by the production
code; update the four cases with names "source space requires node token", "docs
to wiki requires obj type", "docs to wiki requires obj token", and "docs to wiki
requires target space" by adding wantParams fields respectively:
[]string{"--source-space-id"}, []string{"--obj-type"}, []string{"--obj-token"},
and []string{"--target-space-id"} and change the verification to use
errs.ProblemOf (or the existing helper that invokes errs.ProblemOf) to assert
the Problem params match wantParams instead of only checking the error string.

---

Nitpick comments:
In `@shortcuts/wiki/wiki_node_create_test.go`:
- Around line 132-150: The helper requireWikiValidationParams should also assert
the typed problem metadata instead of relying on message substrings: after
confirming err is a *errs.ValidationError, call errs.ProblemOf(err) and verify
problem.Category == errs.CategoryValidation and problem.Subtype ==
errs.SubtypeInvalidArgument, failing the test with t.Fatalf if either check is
false; keep the existing Params name checks (use the existing ve.Params loop) so
callers no longer need to inspect error prose.
🪄 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: d0f55e9e-f028-4d3f-a4b2-c755b736c234

📥 Commits

Reviewing files that changed from the base of the PR and between a98a591 and 25a69d7.

📒 Files selected for processing (24)
  • .golangci.yml
  • lint/errscontract/rule_no_legacy_common_helper_call.go
  • lint/errscontract/rule_no_legacy_envelope_literal.go
  • lint/errscontract/rules_test.go
  • shortcuts/wiki/wiki_async_task.go
  • shortcuts/wiki/wiki_async_task_test.go
  • shortcuts/wiki/wiki_delete.go
  • shortcuts/wiki/wiki_delete_test.go
  • shortcuts/wiki/wiki_list_copy_test.go
  • shortcuts/wiki/wiki_member_add.go
  • shortcuts/wiki/wiki_member_helpers.go
  • shortcuts/wiki/wiki_member_list.go
  • shortcuts/wiki/wiki_member_remove.go
  • shortcuts/wiki/wiki_move.go
  • shortcuts/wiki/wiki_move_test.go
  • shortcuts/wiki/wiki_node_copy.go
  • shortcuts/wiki/wiki_node_create.go
  • shortcuts/wiki/wiki_node_create_test.go
  • shortcuts/wiki/wiki_node_delete.go
  • shortcuts/wiki/wiki_node_delete_test.go
  • shortcuts/wiki/wiki_node_get.go
  • shortcuts/wiki/wiki_node_list.go
  • shortcuts/wiki/wiki_space_create.go
  • shortcuts/wiki/wiki_space_list.go
✅ Files skipped from review due to trivial changes (1)
  • shortcuts/wiki/wiki_member_helpers.go
🚧 Files skipped from review as they are similar to previous changes (18)
  • shortcuts/wiki/wiki_space_list.go
  • lint/errscontract/rule_no_legacy_envelope_literal.go
  • shortcuts/wiki/wiki_member_list.go
  • shortcuts/wiki/wiki_space_create.go
  • shortcuts/wiki/wiki_node_delete_test.go
  • lint/errscontract/rule_no_legacy_common_helper_call.go
  • shortcuts/wiki/wiki_delete.go
  • lint/errscontract/rules_test.go
  • shortcuts/wiki/wiki_member_add.go
  • shortcuts/wiki/wiki_async_task.go
  • .golangci.yml
  • shortcuts/wiki/wiki_node_list.go
  • shortcuts/wiki/wiki_node_get.go
  • shortcuts/wiki/wiki_delete_test.go
  • shortcuts/wiki/wiki_member_remove.go
  • shortcuts/wiki/wiki_node_copy.go
  • shortcuts/wiki/wiki_move.go
  • shortcuts/wiki/wiki_async_task_test.go

Comment thread shortcuts/wiki/wiki_move_test.go
Comment thread shortcuts/wiki/wiki_node_create.go Outdated
@evandance evandance force-pushed the feat/errs-migrate-wiki branch from 25a69d7 to fb86c05 Compare June 9, 2026 13:39

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

🤖 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/wiki/wiki_async_task_test.go`:
- Around line 101-107: The test currently only checks p.Hint text; update it to
also assert the returned problem subtype and that the original transport error
is preserved as the cause: call errs.ProblemOf(err) as before, then assert
p.Subtype (or the concrete typed value returned by ProblemOf) equals the
expected subtype for the fallback branch and use errors.Is(err, transportErr)
(or equivalent) to verify that lastErr/transportErr was preserved via WithCause;
keep the existing p.Hint assertions too so the test verifies subtype, cause
preservation, and hint content together.

In `@shortcuts/wiki/wiki_async_task.go`:
- Around line 103-106: Add a unit test that directly calls
parseWikiAsyncTaskStatus(taskID, nil, resultKey) and asserts it returns an empty
wikiAsyncTaskStatus and an error created via errs.NewInternalError with subtype
errs.SubtypeInvalidResponse; locate the function under test
(parseWikiAsyncTaskStatus) and add a test in the corresponding _test.go that
verifies the error type/subtype and message contract to lock down the new
invalid-response behavior.
- Around line 180-191: In the fallback branch where errs.ProblemOf(lastErr)
returns false (inside the poll error handling in wiki_async_task.go), don't
classify the wrapped error as errs.SubtypeSDKError; instead call
errs.NewInternalError with errs.SubtypeUnknown and preserve the hint and cause
(i.e., replace the NewInternalError(errs.SubtypeSDKError, ...) call with
NewInternalError(errs.SubtypeUnknown, ...) and keep the WithHint and
WithCause(lastErr) chaining) so unclassified lower-layer errors are not
over-classified; keep the existing logic that appends p.Hint when ProblemOf
succeeds and match the behavior of wrapWikiNodeDeleteAPIError.
🪄 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: d748a802-bef5-4761-bcaf-468f9fc832fe

📥 Commits

Reviewing files that changed from the base of the PR and between 25a69d7 and fb86c05.

📒 Files selected for processing (24)
  • .golangci.yml
  • lint/errscontract/rule_no_legacy_common_helper_call.go
  • lint/errscontract/rule_no_legacy_envelope_literal.go
  • lint/errscontract/rules_test.go
  • shortcuts/wiki/wiki_async_task.go
  • shortcuts/wiki/wiki_async_task_test.go
  • shortcuts/wiki/wiki_delete.go
  • shortcuts/wiki/wiki_delete_test.go
  • shortcuts/wiki/wiki_list_copy_test.go
  • shortcuts/wiki/wiki_member_add.go
  • shortcuts/wiki/wiki_member_helpers.go
  • shortcuts/wiki/wiki_member_list.go
  • shortcuts/wiki/wiki_member_remove.go
  • shortcuts/wiki/wiki_move.go
  • shortcuts/wiki/wiki_move_test.go
  • shortcuts/wiki/wiki_node_copy.go
  • shortcuts/wiki/wiki_node_create.go
  • shortcuts/wiki/wiki_node_create_test.go
  • shortcuts/wiki/wiki_node_delete.go
  • shortcuts/wiki/wiki_node_delete_test.go
  • shortcuts/wiki/wiki_node_get.go
  • shortcuts/wiki/wiki_node_list.go
  • shortcuts/wiki/wiki_space_create.go
  • shortcuts/wiki/wiki_space_list.go
✅ Files skipped from review due to trivial changes (1)
  • shortcuts/wiki/wiki_member_helpers.go
🚧 Files skipped from review as they are similar to previous changes (20)
  • shortcuts/wiki/wiki_space_list.go
  • shortcuts/wiki/wiki_delete_test.go
  • shortcuts/wiki/wiki_delete.go
  • lint/errscontract/rules_test.go
  • lint/errscontract/rule_no_legacy_common_helper_call.go
  • shortcuts/wiki/wiki_list_copy_test.go
  • shortcuts/wiki/wiki_node_copy.go
  • shortcuts/wiki/wiki_member_remove.go
  • shortcuts/wiki/wiki_node_delete_test.go
  • shortcuts/wiki/wiki_node_list.go
  • lint/errscontract/rule_no_legacy_envelope_literal.go
  • shortcuts/wiki/wiki_node_create_test.go
  • shortcuts/wiki/wiki_node_get.go
  • shortcuts/wiki/wiki_move_test.go
  • shortcuts/wiki/wiki_space_create.go
  • shortcuts/wiki/wiki_member_add.go
  • shortcuts/wiki/wiki_node_delete.go
  • shortcuts/wiki/wiki_node_create.go
  • .golangci.yml
  • shortcuts/wiki/wiki_move.go

Comment thread shortcuts/wiki/wiki_async_task_test.go
Comment thread shortcuts/wiki/wiki_async_task.go
Comment thread shortcuts/wiki/wiki_async_task.go Outdated
@evandance evandance force-pushed the feat/errs-migrate-wiki branch from fb86c05 to 7113a61 Compare June 9, 2026 13:57

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
shortcuts/wiki/wiki_node_list.go (1)

169-176: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add a non-advancing cursor guard in node auto-pagination.

With --page-all and --page-limit 0, a buggy API that returns the same page_token with has_more=true can loop forever. fetchWikiMembers already protects this case; fetchWikiNodes should mirror it.

Suggested fix
 		if !lastHasMore || lastPageToken == "" {
 			break
 		}
+		if lastPageToken == pageToken {
+			fmt.Fprintf(runtime.IO().ErrOut, "Stopping pagination: server returned a non-advancing page_token.\n")
+			break
+		}
 		if pageLimit > 0 && page+1 >= pageLimit {
 			break
 		}
🤖 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/wiki/wiki_node_list.go` around lines 169 - 176, The auto-pagination
loop in fetchWikiNodes can enter an infinite loop if the API returns the same
page_token with has_more=true; add a non-advancing cursor guard like in
fetchWikiMembers: track the previous pageToken (e.g., lastPageToken) and after
computing lastPageToken compare it to the current pageToken, and break the loop
if they are equal (or if lastPageToken == ""). Ensure you update/assign
lastPageToken appropriately inside the loop before checking
lastHasMore/pageLimit and set pageToken = lastPageToken only when it advanced;
mirror the same guard logic used in fetchWikiMembers to prevent infinite loops.
🤖 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.

Outside diff comments:
In `@shortcuts/wiki/wiki_node_list.go`:
- Around line 169-176: The auto-pagination loop in fetchWikiNodes can enter an
infinite loop if the API returns the same page_token with has_more=true; add a
non-advancing cursor guard like in fetchWikiMembers: track the previous
pageToken (e.g., lastPageToken) and after computing lastPageToken compare it to
the current pageToken, and break the loop if they are equal (or if lastPageToken
== ""). Ensure you update/assign lastPageToken appropriately inside the loop
before checking lastHasMore/pageLimit and set pageToken = lastPageToken only
when it advanced; mirror the same guard logic used in fetchWikiMembers to
prevent infinite loops.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1c7285bd-8a34-4d0c-ab15-445e14e7409d

📥 Commits

Reviewing files that changed from the base of the PR and between fb86c05 and 7113a61.

📒 Files selected for processing (24)
  • .golangci.yml
  • lint/errscontract/rule_no_legacy_common_helper_call.go
  • lint/errscontract/rule_no_legacy_envelope_literal.go
  • lint/errscontract/rules_test.go
  • shortcuts/wiki/wiki_async_task.go
  • shortcuts/wiki/wiki_async_task_test.go
  • shortcuts/wiki/wiki_delete.go
  • shortcuts/wiki/wiki_delete_test.go
  • shortcuts/wiki/wiki_list_copy_test.go
  • shortcuts/wiki/wiki_member_add.go
  • shortcuts/wiki/wiki_member_helpers.go
  • shortcuts/wiki/wiki_member_list.go
  • shortcuts/wiki/wiki_member_remove.go
  • shortcuts/wiki/wiki_move.go
  • shortcuts/wiki/wiki_move_test.go
  • shortcuts/wiki/wiki_node_copy.go
  • shortcuts/wiki/wiki_node_create.go
  • shortcuts/wiki/wiki_node_create_test.go
  • shortcuts/wiki/wiki_node_delete.go
  • shortcuts/wiki/wiki_node_delete_test.go
  • shortcuts/wiki/wiki_node_get.go
  • shortcuts/wiki/wiki_node_list.go
  • shortcuts/wiki/wiki_space_create.go
  • shortcuts/wiki/wiki_space_list.go
🚧 Files skipped from review as they are similar to previous changes (22)
  • shortcuts/wiki/wiki_member_helpers.go
  • lint/errscontract/rule_no_legacy_envelope_literal.go
  • shortcuts/wiki/wiki_space_list.go
  • shortcuts/wiki/wiki_async_task_test.go
  • shortcuts/wiki/wiki_member_remove.go
  • lint/errscontract/rule_no_legacy_common_helper_call.go
  • shortcuts/wiki/wiki_move_test.go
  • shortcuts/wiki/wiki_delete.go
  • shortcuts/wiki/wiki_node_delete_test.go
  • shortcuts/wiki/wiki_list_copy_test.go
  • shortcuts/wiki/wiki_space_create.go
  • shortcuts/wiki/wiki_member_add.go
  • lint/errscontract/rules_test.go
  • shortcuts/wiki/wiki_delete_test.go
  • shortcuts/wiki/wiki_node_create_test.go
  • shortcuts/wiki/wiki_async_task.go
  • shortcuts/wiki/wiki_node_copy.go
  • shortcuts/wiki/wiki_node_get.go
  • .golangci.yml
  • shortcuts/wiki/wiki_move.go
  • shortcuts/wiki/wiki_node_delete.go
  • shortcuts/wiki/wiki_node_create.go

@evandance evandance force-pushed the feat/errs-migrate-wiki branch 2 times, most recently from 1489037 to 905858f Compare June 10, 2026 06:12
Emit structured validation, API, network, file, and internal error envelopes for Wiki shortcuts so users and agents can recover from failed wiki workflows using stable type, subtype, param, and code fields.

Add Wiki domain errscontract and golangci guards to prevent legacy envelope and common helper regressions.
@evandance evandance force-pushed the feat/errs-migrate-wiki branch from 905858f to c2ca5d8 Compare June 10, 2026 10:48
@evandance evandance merged commit 154ecdb into main Jun 11, 2026
20 checks passed
@evandance evandance deleted the feat/errs-migrate-wiki branch June 11, 2026 06:02
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 feature 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