Skip to content

Propagate DB errors in CategoryFilter.Get - #1076

Open
Atishyy27 wants to merge 1 commit into
meshery:masterfrom
Atishyy27:fix/1075-categoryfilter-swallowed-error
Open

Propagate DB errors in CategoryFilter.Get#1076
Atishyy27 wants to merge 1 commit into
meshery:masterfrom
Atishyy27:fix/1075-categoryfilter-swallowed-error

Conversation

@Atishyy27

@Atishyy27 Atishyy27 commented Jul 28, 2026

Copy link
Copy Markdown

Fixes #1075.

What

CategoryFilter.Get dropped the error from finder.Find and returned an empty result with a nil error:

err := finder.Find(&catdb).Error
if err != nil {
    return cat, count, int(count), nil   // swallowed
}

So a real query failure (e.g. a bad OrderOn column from a caller-supplied sort param → SQL error, or a transient DB error) surfaced as an empty category list reported as success — nothing returned to the client, nothing logged.

Change

Return nil, 0, 0, err, matching every sibling filter — ModelFilter.Get and ConnectionFilter.Get both already propagate the error this way. CategoryFilter was the only outlier.

Testing

One-line change; GOOS=linux go build ./models/meshmodel/registry/... and go vet both pass. Behaviour for the success path is unchanged.

Summary by CodeRabbit

  • Bug Fixes
    • Corrected category filtering error handling so failed requests now return the appropriate error instead of appearing successful.
    • Ensured pagination counts are reset when category data cannot be retrieved.

CategoryFilter.Get dropped the error from finder.Find and returned an empty
result with a nil error, so a real query failure surfaced as an empty
category list reported as success. Every sibling filter (ModelFilter,
ConnectionFilter) returns the error instead.

Return nil, 0, 0, err to match them.

Fixes meshery#1075

Signed-off-by: Atishyy27 <sethatishayjain@gmail.com>
@welcome

welcome Bot commented Jul 28, 2026

Copy link
Copy Markdown

Yay, your first pull request! 👍 A contributor will be by to give feedback soon. In the meantime, you can find updates in the #github-notifications channel in the community Slack.
Be sure to double-check that you have signed your commits. Here are instructions for making signing an implicit activity while performing a commit.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a5e854cc-1073-4f2f-a626-84ef358ee26f

📥 Commits

Reviewing files that changed from the base of the PR and between 6f8803d and 58cbae2.

📒 Files selected for processing (1)
  • models/meshmodel/registry/v1beta1/category_filter.go

📝 Walkthrough

Walkthrough

CategoryFilter.Get now propagates errors from finder.Find(&catdb) and returns nil results with zero pagination counts when the database query fails.

Changes

Category filter error handling

Layer / File(s) Summary
Propagate finder errors
models/meshmodel/registry/v1beta1/category_filter.go
CategoryFilter.Get returns nil, 0, 0, err when the category query fails instead of returning an empty result with a nil error.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the change: CategoryFilter.Get now propagates database errors instead of swallowing them.
Linked Issues check ✅ Passed The one-line fix implements #1075 by returning the finder error with nil results and zero counts, matching sibling filters.
Out of Scope Changes check ✅ Passed The PR appears narrowly scoped to the error-propagation fix in CategoryFilter.Get with no unrelated code changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

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.

CategoryFilter.Get swallows database errors and returns an empty result as success

1 participant