Skip to content

Skip component definitions with no status during registration - #1078

Open
Atishyy27 wants to merge 2 commits into
meshery:masterfrom
Atishyy27:fix/1077-register-nil-status
Open

Skip component definitions with no status during registration#1078
Atishyy27 wants to merge 2 commits into
meshery:masterfrom
Atishyy27:fix/1077-register-nil-status

Conversation

@Atishyy27

@Atishyy27 Atishyy27 commented Jul 28, 2026

Copy link
Copy Markdown

Fixes #1077.

What

register() dereferenced *comp.Status unconditionally. ComponentDefinition.Status is a *ComponentDefinitionStatus and getEntity unmarshals definitions without requiring it, so a definition that omits status unmarshals with Status == nil and panics on the first component — aborting the entire import batch before the loop's per-item error handling can skip just the bad item.

Change

Guard comp.Status == nil: record an InsertEntityRegError for that component and continue, exactly how the loop already handles other per-item failures (RegisterEntity errors).

Testing

GOOS=linux go build ./models/registration/ and go vet both pass. No behaviour change for components that have a status.

Summary by CodeRabbit

  • Bug Fixes
    • Query failures now correctly return an error instead of appearing successful with incomplete or misleading results.
    • Registration now handles components with missing status information safely, reporting the issue and continuing without interruption to other components.

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>
register() dereferenced *comp.Status unconditionally, so a component
definition unmarshalled without a status (Status == nil) panicked on the
first component of the loop, aborting the whole import batch before the
per-item error handling could skip just the bad item.

Guard against a nil Status and record an entity registration error for that
component, then continue - matching how the loop already handles other
per-item failures.

Fixes meshery#1077

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

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The changes propagate database errors from category filtering and prevent registration from dereferencing nil component statuses by recording an error and continuing with subsequent components.

Changes

Category filter error propagation

Layer / File(s) Summary
Category filter error returns
models/meshmodel/registry/v1beta1/category_filter.go
CategoryFilter.Get now returns nil entities, zero pagination values, and the database error when finder.Find fails.

Registration status validation

Layer / File(s) Summary
Nil status handling
models/registration/register.go
Component registration imports fmt, records an error for components with nil status, and continues processing remaining components.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • meshery/meshkit issue 1075 — Covers the same CategoryFilter.Get database-error propagation change.

Possibly related PRs

  • meshery/meshkit#1076 — Updates the same CategoryFilter.Get error path to propagate database errors.

Suggested reviewers: aabidsofi19

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The CategoryFilter.Get error-handling change is unrelated to the registration status fix in #1077. Remove the CategoryFilter.Get change or split it into a separate PR if it is a distinct fix.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: skipping components without status during registration.
Linked Issues check ✅ Passed The registration change matches #1077 by guarding nil component status and continuing batch processing instead of panicking.
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.

@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)
models/registration/register.go (1)

116-120: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add regression coverage for nil status and batch continuation.

Test a batch containing one statusless component followed by a valid component; assert that InsertEntityRegError is recorded and the valid component is still registered.

🤖 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 `@models/registration/register.go` around lines 116 - 120, Add regression
coverage for the registration flow around the nil-status check in the batch
handler: submit a statusless component followed by a valid component, assert
that InsertEntityRegError records the statusless component’s failure, and verify
the valid component is still registered.
🤖 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 `@models/registration/register.go`:
- Around line 116-120: Add regression coverage for the registration flow around
the nil-status check in the batch handler: submit a statusless component
followed by a valid component, assert that InsertEntityRegError records the
statusless component’s failure, and verify the valid component is still
registered.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 030187fa-f25c-4e1a-b216-7999bce0e3c0

📥 Commits

Reviewing files that changed from the base of the PR and between 6f8803d and 0feb1e2.

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

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.

Registration panics on a component definition with no status

1 participant