Skip component definitions with no status during registration - #1078
Skip component definitions with no status during registration#1078Atishyy27 wants to merge 2 commits into
Conversation
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>
📝 WalkthroughWalkthroughThe changes propagate database errors from category filtering and prevent registration from dereferencing nil component statuses by recording an error and continuing with subsequent components. ChangesCategory filter error propagation
Registration status validation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
models/registration/register.go (1)
116-120: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd regression coverage for nil status and batch continuation.
Test a batch containing one statusless component followed by a valid component; assert that
InsertEntityRegErroris 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
📒 Files selected for processing (2)
models/meshmodel/registry/v1beta1/category_filter.gomodels/registration/register.go
Fixes #1077.
What
register()dereferenced*comp.Statusunconditionally.ComponentDefinition.Statusis a*ComponentDefinitionStatusandgetEntityunmarshals definitions without requiring it, so a definition that omitsstatusunmarshals withStatus == niland 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 anInsertEntityRegErrorfor that component andcontinue, exactly how the loop already handles other per-item failures (RegisterEntity errors).Testing
GOOS=linux go build ./models/registration/andgo vetboth pass. No behaviour change for components that have a status.Summary by CodeRabbit