fix(base): improve dashboard data diagnostics and slim lark-base skill#1601
fix(base): improve dashboard data diagnostics and slim lark-base skill#1601zhouyue-bytedance wants to merge 1 commit into
Conversation
- diagnose empty dashboard measure values so agents don't report success on empty charts - clarify dashboard text readback in record markdown - slim lark-base SKILL routing, clarify dashboard parameter traps, limit broad verification - accept --json output shorthand on record list
📝 WalkthroughWalkthroughThis PR adds dashboard block diagnostics for JSON-encoded text and missing computed measure values, introduces a hidden ChangesDashboard diagnostics
Record-list JSON alias
Sequence Diagram(s)sequenceDiagram
participant executeDashboardBlockGetData
participant attachDashboardBlockDataDiagnostics
participant extractMeasureAliases
participant hasComputedMeasureValues
participant appendDashboardDiagnostic
executeDashboardBlockGetData->>attachDashboardBlockDataDiagnostics: inspect block data
attachDashboardBlockDataDiagnostics->>extractMeasureAliases: read measures
attachDashboardBlockDataDiagnostics->>hasComputedMeasureValues: scan main_data rows
hasComputedMeasureValues-->>attachDashboardBlockDataDiagnostics: missing computed values
attachDashboardBlockDataDiagnostics->>appendDashboardDiagnostic: add empty_measure_values
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ 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 |
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@3a9e0aa314656747fdfc24ef32291414c1dad801🧩 Skill updatenpx skills add zhouyue-bytedance/cli#pr-base-dashboard -y -g |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
shortcuts/base/record_markdown.go (1)
40-43: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider documenting the
--jsonsemantic split across base record commands. Within the base family,--jsonmeans "output as JSON" for+record-listbut means "JSON request body" for+record-search/+record-get. This is a deliberate divergence, but it can confuse users/agents reusing flags across subcommands. A short inline comment near this helper (or in the flag description) noting the distinction would help future maintainers.🤖 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/base/record_markdown.go` around lines 40 - 43, Add a brief inline comment near recordReadJSONOutputAlias in shortcuts/base/record_markdown.go clarifying that --json has different meanings across base record commands: it means output-as-JSON for record-list, but request-body JSON for record-search and record-get. Keep the note close to the helper or the related flag definition so future maintainers can find the semantic split quickly.
🤖 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/base/dashboard_ops.go`:
- Around line 282-304: The empty-measure diagnostic in dashboard block data
handling is skipped when main_data has zero rows, so the zero-result chart case
is treated as success. Update dashboardBlockRowHasMeasureValue-related logic in
dashboard_ops.go to emit the same empty_measure_values diagnostic whenever
measures are declared and main_data is empty, not just when rows exist but lack
computed values, and add a regression test in
TestBaseDashboardBlockExecuteGetData covering the zero-row case.
---
Nitpick comments:
In `@shortcuts/base/record_markdown.go`:
- Around line 40-43: Add a brief inline comment near recordReadJSONOutputAlias
in shortcuts/base/record_markdown.go clarifying that --json has different
meanings across base record commands: it means output-as-JSON for record-list,
but request-body JSON for record-search and record-get. Keep the note close to
the helper or the related flag definition so future maintainers can find the
semantic split quickly.
🪄 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: d6e80fe2-98bc-4f00-903e-14bfce33835f
📒 Files selected for processing (9)
shortcuts/base/base_dashboard_execute_test.goshortcuts/base/base_execute_test.goshortcuts/base/base_shortcuts_test.goshortcuts/base/dashboard_ops.goshortcuts/base/record_list.goshortcuts/base/record_markdown.goshortcuts/base/record_ops.goskills/lark-base/SKILL.mdtests/cli_e2e/base/base_record_list_dryrun_test.go
| rows, ok := data["main_data"].([]interface{}) | ||
| if !ok || len(rows) == 0 { | ||
| return | ||
| } | ||
| for _, rawRow := range rows { | ||
| row, ok := rawRow.(map[string]interface{}) | ||
| if !ok { | ||
| continue | ||
| } | ||
| if dashboardBlockRowHasMeasureValue(row, measureAliases) { | ||
| return | ||
| } | ||
| } | ||
| data["_diagnostics"] = []interface{}{ | ||
| map[string]interface{}{ | ||
| "type": "empty_measure_values", | ||
| "message": "chart data defines measures, but main_data rows contain no computed measure values", | ||
| "hint": "Recreate or update the block data_config with a computable numeric measure or count_all, then rerun +dashboard-block-get-data before declaring the chart complete.", | ||
| "measure_aliases": measureAliases, | ||
| "main_data_rows": len(rows), | ||
| }, | ||
| } | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Emit empty_measure_values for zero-row results too.
Line 283 returns before adding diagnostics when main_data is empty, so a block with declared measures but zero result rows still looks like a clean success. That misses the exact “empty chart” case this change is trying to surface. Please emit the same diagnostic when measures exist and main_data is [], and add the matching regression case in TestBaseDashboardBlockExecuteGetData.
Proposed fix
func attachDashboardBlockDataDiagnostics(data map[string]interface{}) {
measureAliases := dashboardBlockMeasureAliases(data["measures"])
if len(measureAliases) == 0 {
return
}
rows, ok := data["main_data"].([]interface{})
- if !ok || len(rows) == 0 {
+ if !ok {
return
}
+ if len(rows) == 0 {
+ appendDashboardDiagnostic(data, map[string]interface{}{
+ "type": "empty_measure_values",
+ "message": "chart data defines measures, but main_data rows contain no computed measure values",
+ "hint": "Recreate or update the block data_config with a computable numeric measure or count_all, then rerun +dashboard-block-get-data before declaring the chart complete.",
+ "measure_aliases": measureAliases,
+ "main_data_rows": 0,
+ })
+ return
+ }
for _, rawRow := range rows {
row, ok := rawRow.(map[string]interface{})
if !ok {
continue
}
if dashboardBlockRowHasMeasureValue(row, measureAliases) {
return
}
}
- data["_diagnostics"] = []interface{}{
- map[string]interface{}{
- "type": "empty_measure_values",
- "message": "chart data defines measures, but main_data rows contain no computed measure values",
- "hint": "Recreate or update the block data_config with a computable numeric measure or count_all, then rerun +dashboard-block-get-data before declaring the chart complete.",
- "measure_aliases": measureAliases,
- "main_data_rows": len(rows),
- },
- }
+ appendDashboardDiagnostic(data, map[string]interface{}{
+ "type": "empty_measure_values",
+ "message": "chart data defines measures, but main_data rows contain no computed measure values",
+ "hint": "Recreate or update the block data_config with a computable numeric measure or count_all, then rerun +dashboard-block-get-data before declaring the chart complete.",
+ "measure_aliases": measureAliases,
+ "main_data_rows": len(rows),
+ })
}📝 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.
| rows, ok := data["main_data"].([]interface{}) | |
| if !ok || len(rows) == 0 { | |
| return | |
| } | |
| for _, rawRow := range rows { | |
| row, ok := rawRow.(map[string]interface{}) | |
| if !ok { | |
| continue | |
| } | |
| if dashboardBlockRowHasMeasureValue(row, measureAliases) { | |
| return | |
| } | |
| } | |
| data["_diagnostics"] = []interface{}{ | |
| map[string]interface{}{ | |
| "type": "empty_measure_values", | |
| "message": "chart data defines measures, but main_data rows contain no computed measure values", | |
| "hint": "Recreate or update the block data_config with a computable numeric measure or count_all, then rerun +dashboard-block-get-data before declaring the chart complete.", | |
| "measure_aliases": measureAliases, | |
| "main_data_rows": len(rows), | |
| }, | |
| } | |
| } | |
| rows, ok := data["main_data"].([]interface{}) | |
| if !ok { | |
| return | |
| } | |
| if len(rows) == 0 { | |
| appendDashboardDiagnostic(data, map[string]interface{}{ | |
| "type": "empty_measure_values", | |
| "message": "chart data defines measures, but main_data rows contain no computed measure values", | |
| "hint": "Recreate or update the block data_config with a computable numeric measure or count_all, then rerun +dashboard-block-get-data before declaring the chart complete.", | |
| "measure_aliases": measureAliases, | |
| "main_data_rows": 0, | |
| }) | |
| return | |
| } | |
| for _, rawRow := range rows { | |
| row, ok := rawRow.(map[string]interface{}) | |
| if !ok { | |
| continue | |
| } | |
| if dashboardBlockRowHasMeasureValue(row, measureAliases) { | |
| return | |
| } | |
| } | |
| appendDashboardDiagnostic(data, map[string]interface{}{ | |
| "type": "empty_measure_values", | |
| "message": "chart data defines measures, but main_data rows contain no computed measure values", | |
| "hint": "Recreate or update the block data_config with a computable numeric measure or count_all, then rerun +dashboard-block-get-data before declaring the chart complete.", | |
| "measure_aliases": measureAliases, | |
| "main_data_rows": len(rows), | |
| }) | |
| } |
🤖 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/base/dashboard_ops.go` around lines 282 - 304, The empty-measure
diagnostic in dashboard block data handling is skipped when main_data has zero
rows, so the zero-result chart case is treated as success. Update
dashboardBlockRowHasMeasureValue-related logic in dashboard_ops.go to emit the
same empty_measure_values diagnostic whenever measures are declared and
main_data is empty, not just when rows exist but lack computed values, and add a
regression test in TestBaseDashboardBlockExecuteGetData covering the zero-row
case.
What
--jsonoutput shorthand on+record-list.Scope
base dashboard ops, record list
--jsonshorthand, record markdown, and the lark-base skill doc. No unrelated files.Summary by CodeRabbit
New Features
--jsonshortcut for record list output, making JSON mode easier to access.Bug Fixes