chore: surface error if getProviderId called on resource without proivder#67
chore: surface error if getProviderId called on resource without proivder#67adityachoudhari26 wants to merge 1 commit intomainfrom
Conversation
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/api/providers/resource.go (1)
130-134: Consider including resource identifier in error message for easier debugging.When multiple resources are processed, identifying which one lacks a provider can be difficult with a generic error. Including the identifier would help users quickly locate the problematic resource definition.
Suggested improvement
func (r *ResourceItemSpec) getProviderID(ctx Context) (string, error) { providerName := r.Provider if providerName == "" { - return "", fmt.Errorf("resource has no provider") + return "", fmt.Errorf("resource %q has no provider", r.Identifier) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@internal/api/providers/resource.go` around lines 130 - 134, The error returned from ResourceItemSpec.getProviderID is too generic; update the function to include the resource's identifier in the error message so callers can pinpoint which resource is missing a provider. Locate ResourceItemSpec.getProviderID and change the error path that returns fmt.Errorf("resource has no provider") to include a unique field from the receiver (e.g., r.ID, r.Name, or another identifier available on ResourceItemSpec) so the message becomes something like "resource <identifier> has no provider" and still returns the same error type.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@internal/api/providers/resource.go`:
- Around line 130-134: The error returned from ResourceItemSpec.getProviderID is
too generic; update the function to include the resource's identifier in the
error message so callers can pinpoint which resource is missing a provider.
Locate ResourceItemSpec.getProviderID and change the error path that returns
fmt.Errorf("resource has no provider") to include a unique field from the
receiver (e.g., r.ID, r.Name, or another identifier available on
ResourceItemSpec) so the message becomes something like "resource <identifier>
has no provider" and still returns the same error type.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 38b94872-ce7d-436b-8250-93359c3871bb
📒 Files selected for processing (1)
internal/api/providers/resource.go
Summary by CodeRabbit