Skip to content

Improve mtree build message on an empty table#148

Merged
mason-sharp merged 1 commit into
mainfrom
ACE-204
Jul 17, 2026
Merged

Improve mtree build message on an empty table#148
mason-sharp merged 1 commit into
mainfrom
ACE-204

Conversation

@zaidshabbir25

@zaidshabbir25 zaidshabbir25 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Improve mtree build message on an empty table

ACE-204

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

The Merkle tree builder now handles unavailable and all-zero row estimates explicitly, and an integration test verifies the empty-table error message and pool cleanup behavior.

Empty-table Merkle handling

Layer / File(s) Summary
Row-estimate validation and integration coverage
internal/consistency/mtree/merkle.go, tests/integration/mtree_empty_table_test.go
BuildMtree tracks successful estimates, selects the first successful node as the reference, reports distinct errors for failed estimates and zero-row tables, and the integration test validates the user-facing error.

Poem

I’m a rabbit with a table so bare,
No rows in the burrows anywhere.
The tree now speaks, “Zero rows found!”
And closes every pool around.
No secret reference-node despair—
Just a clear message in the air.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly matches the main change: improving the mtree build message for empty tables.
Description check ✅ Passed The description is relevant and matches the changeset, noting the mtree build message improvement on empty tables.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ACE-204

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.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 5 complexity · 2 duplication

Metric Results
Complexity 5
Duplication 2

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

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

🧹 Nitpick comments (1)
internal/consistency/mtree/merkle.go (1)

1532-1544: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Rely on the deferred cleanup to close pools.

The explicit loops to close the pools before returning are redundant. The defer registered at the beginning of the function (line 1477) executes immediately upon any return, ensuring all pools are closed safely without needing manual intervention on each error path.

(You can also safely remove the identical loop around line 1510 for the same reason.)

♻️ Proposed refactor
 	if successfulEstimates == 0 {
-		for _, p := range pools {
-			p.Close()
-		}
 		return fmt.Errorf("could not determine a reference node; failed to get row estimates from all nodes")
 	}

 	if maxRows == 0 {
-		for _, p := range pools {
-			p.Close()
-		}
 		return fmt.Errorf("table %s has 0 rows on all nodes; add data before building a Merkle tree", m.QualifiedTableName)
 	}
🤖 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 `@internal/consistency/mtree/merkle.go` around lines 1532 - 1544, Remove the
explicit pool-closing loops before the returns for the successfulEstimates == 0
and maxRows == 0 checks, and also remove the identical loop around the earlier
error path near line 1510. Rely on the defer registered at the start of the
containing function to close all pools on every return.
🤖 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.

Nitpick comments:
In `@internal/consistency/mtree/merkle.go`:
- Around line 1532-1544: Remove the explicit pool-closing loops before the
returns for the successfulEstimates == 0 and maxRows == 0 checks, and also
remove the identical loop around the earlier error path near line 1510. Rely on
the defer registered at the start of the containing function to close all pools
on every return.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cf67fcb0-8aba-4774-a895-2451b648a4c6

📥 Commits

Reviewing files that changed from the base of the PR and between 3653ae2 and fbb46ee.

📒 Files selected for processing (2)
  • internal/consistency/mtree/merkle.go
  • tests/integration/mtree_empty_table_test.go

@mason-sharp mason-sharp changed the title ACE-204 Improve mtree build message on an empty table Improve mtree build message on an empty table Jul 17, 2026
@mason-sharp
mason-sharp merged commit 108b036 into main Jul 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants