fix: preserve slides schema issues#1948
Conversation
📝 WalkthroughWalkthroughSlides creation and page replacement commands now preserve schema issue details returned by Slides API responses. Creation exposes top-level and per-slide issues, while page replacement includes issues in affected page results with corresponding test coverage. ChangesSlides issue propagation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
shortcuts/slides/slides_create.go (1)
188-218: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick winAvoid introducing new loose-map structures.
The
slideIssuesslice is constructed using inlinemap[string]interface{}literals. As per coding guidelines, do not introduce new loose-map code for structured data. Instead, define and use a local struct withjsontags.♻️ Proposed refactor to use a typed struct
- var slideIssues []map[string]interface{} + type slideIssue struct { + SlideIndex int `json:"slide_index"` + SlideID string `json:"slide_id"` + Issues interface{} `json:"issues"` + } + var slideIssues []slideIssue for i, slideXML := range slides { slideData, err := runtime.CallAPITyped( "POST", slideURL, map[string]interface{}{"revision_id": -1}, map[string]interface{}{ "slide": map[string]interface{}{"content": slideXML}, }, ) if err != nil { return appendSlidesProgressHint(err, fmt.Sprintf("adding slide %d/%d failed; presentation %s was created, %d slide(s) added before failure", i+1, len(slides), presentationID, i)) } sid := common.GetString(slideData, "slide_id") if sid != "" { slideIDs = append(slideIDs, sid) } if issues, ok := slideData["issues"]; ok { - slideIssues = append(slideIssues, map[string]interface{}{ - "slide_index": i + 1, - "slide_id": sid, - "issues": issues, - }) + slideIssues = append(slideIssues, slideIssue{ + SlideIndex: i + 1, + SlideID: sid, + Issues: issues, + }) } } result["slide_ids"] = slideIDs result["slides_added"] = len(slideIDs) if len(slideIssues) > 0 { result["slide_issues"] = slideIssues }🤖 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/slides/slides_create.go` around lines 188 - 218, Replace the loose-map slideIssues collection in the slide creation loop with a local typed struct containing slide_index, slide_id, and issues fields, each using the appropriate json tags. Use a slice of that struct and append typed values while preserving the existing result["slide_issues"] output and behavior.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.
Outside diff comments:
In `@shortcuts/slides/slides_create.go`:
- Around line 188-218: Replace the loose-map slideIssues collection in the slide
creation loop with a local typed struct containing slide_index, slide_id, and
issues fields, each using the appropriate json tags. Use a slice of that struct
and append typed values while preserving the existing result["slide_issues"]
output and behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ed6aaa41-57dd-417f-bf06-2c9244cd8ad8
📒 Files selected for processing (4)
shortcuts/slides/slides_create.goshortcuts/slides/slides_create_test.goshortcuts/slides/slides_replace_pages.goshortcuts/slides/slides_replace_pages_test.go
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@f826a726064a22a026a8ca550a1cfc15939a1a91🧩 Skill updatenpx skills add larksuite/cli#feat/slides_table_lint -y -g |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1948 +/- ##
=======================================
Coverage 75.02% 75.03%
=======================================
Files 894 894
Lines 94294 94310 +16
=======================================
+ Hits 70746 70762 +16
Misses 18137 18137
Partials 5411 5411 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Expose non-fatal Slides XML schema issues through the shortcut output, so callers can see server-side validation warnings.
Changes
slides +create.slides +replace-pages.Test Plan
Related Issues
Summary by CodeRabbit
Bug Fixes
Tests