-
Notifications
You must be signed in to change notification settings - Fork 24
HYPERFLEET-1345 - fix: Address bugs from PR#288 #310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,7 @@ type ResourceDao interface { | |
| FindByKindAndOwnerForUpdate(ctx context.Context, kind, ownerID string) (api.ResourceList, error) | ||
| GetByID(ctx context.Context, id string) (*api.Resource, error) | ||
| ReplaceReferences(ctx context.Context, sourceID string, refs []api.ResourceReference) error | ||
| FindReferencer(ctx context.Context, targetID string) (*api.ResourceSummary, error) | ||
| FindReferencers(ctx context.Context, targetID string) ([]api.ResourceSummary, error) | ||
| ClearTargetReferences(ctx context.Context, targetID string) error | ||
| FindSourceIDsByRef(ctx context.Context, refType, targetID string) ([]string, error) | ||
| } | ||
|
|
@@ -196,26 +196,22 @@ func (d *sqlResourceDao) ReplaceReferences( | |
| return nil | ||
| } | ||
|
|
||
| // FindReferencer returns the first non-deleted resource that references targetID, | ||
| // FindReferencers returns the list of resources that references targetID, | ||
| // or nil if none exists. Used as an existence check for 409 conflict responses. | ||
| func (d *sqlResourceDao) FindReferencer( | ||
| func (d *sqlResourceDao) FindReferencers( | ||
| ctx context.Context, targetID string, | ||
| ) (*api.ResourceSummary, error) { | ||
| ) ([]api.ResourceSummary, error) { | ||
| g2 := d.sessionFactory.New(ctx) | ||
| var summary api.ResourceSummary | ||
| var summaries []api.ResourceSummary | ||
| err := g2.Model(&api.ResourceReference{}). | ||
| Select("resources.kind, resources.name"). | ||
| Joins("JOIN resources ON resource_references.source_id = resources.id"). | ||
| Where("resource_references.target_id = ? AND resources.deleted_time IS NULL", targetID). | ||
| Limit(1). | ||
| Scan(&summary).Error | ||
| Scan(&summaries).Error | ||
| if err != nil { | ||
| return nil, err | ||
|
Comment on lines
211
to
212
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win Wrap the DAO error with target context. Returning As per path instructions, errors must be wrapped per the Error Model Standard; a raw error return is not sufficient. 🤖 Prompt for AI AgentsSource: Path instructions |
||
| } | ||
| if summary.Kind == "" { | ||
| return nil, nil | ||
| } | ||
| return &summary, nil | ||
| return summaries, nil | ||
| } | ||
|
|
||
| // ClearTargetReferences removes all inbound references pointing at targetID. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.