fix(docs): resolve wiki links before fetch#1563
Conversation
Spec source: active@85525615e67bcb34cfd5186f32625cdc11091edd324351ba4dd374f837bd6efd
|
|
📝 WalkthroughWalkthroughAdds wiki URL support to the ChangesWiki document resolution for docs +fetch
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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/doc/helpers.go`:
- Line 97: The validation error in the wiki type mismatch path is mixing the
failure message with recovery guidance. Update the return in the relevant helper
that builds the `errs.NewValidationError(...)` so the message only states that
`docs +fetch` resolved to the wrong wiki node type, and move the “use the
matching shortcut / run drive +inspect” text into `.WithHint(...)` on that
error. Keep `docShortcutHintForWikiType(...)` as the source for the typed
guidance so callers and tests can consume it consistently.
🪄 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: a3aa2f2b-1bae-4929-8250-2bf5715b397a
📒 Files selected for processing (4)
shortcuts/doc/doc_media_test.goshortcuts/doc/docs_fetch_v2.goshortcuts/doc/docs_fetch_v2_test.goshortcuts/doc/helpers.go
| return "", errs.NewInternalError(errs.SubtypeInvalidResponse, "wiki get_node returned incomplete node data (obj_type=%q, obj_token=%q)", objType, objToken) | ||
| } | ||
| if objType != "docx" && objType != "doc" { | ||
| return "", errs.NewValidationError(errs.SubtypeInvalidArgument, "wiki resolved to %q, but docs +fetch requires a doc/docx wiki node; use the matching %s shortcut or run drive +inspect to inspect the underlying type", objType, docShortcutHintForWikiType(objType)).WithParam("--doc") |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Move remediation guidance into .WithHint(...).
Line 97 puts recovery guidance in the validation error message. Keep the message focused on the failure and move “use the matching shortcut / drive +inspect” into .WithHint(...) so callers/tests can consume typed guidance consistently.
As per coding guidelines, “recovery guidance goes in .WithHint(...).”
🤖 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` at line 97, The validation error in the wiki type
mismatch path is mixing the failure message with recovery guidance. Update the
return in the relevant helper that builds the `errs.NewValidationError(...)` so
the message only states that `docs +fetch` resolved to the wrong wiki node type,
and move the “use the matching shortcut / run drive +inspect” text into
`.WithHint(...)` on that error. Keep `docShortcutHintForWikiType(...)` as the
source for the typed guidance so callers and tests can consume it consistently.
Source: Coding guidelines
Summary
wiki/v2/spaces/get_nodebefore callingdocs_ai/v1/documents/:document_id/fetch.Fixes #1034
Validation
go test ./shortcuts/doc -run 'TestDocsFetchWiki|TestDocsFetchDryRunWiki'go test ./shortcuts/docmake unit-testmake fmt-checkmake vetgit diff --checkSummary by CodeRabbit
New Features
docs +fetchnow supports wiki document links by resolving them to the underlying document before fetching.Bug Fixes
Tests