-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[CHORE] Reimplement fork backstop #4511
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 | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -967,7 +967,10 @@ func (tc *Catalog) ForkCollection(ctx context.Context, forkCollection *model.For | |||||||||||||||
if err != nil { | ||||||||||||||||
return err | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
// Defensive backstop to prevent too many forks | ||||||||||||||||
if len(lineageFile.Dependencies) > 1000000 { | ||||||||||||||||
return common.ErrCollectionTooManyFork | ||||||||||||||||
Comment on lines
+970
to
+972
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. [BestPractice] Consider making the hard-coded limit of 1,000,000 forks configurable through a constant variable at the package level. This would improve maintainability and make it easier to adjust the limit in the future without modifying the function code.
Suggested change
⚡ Committable suggestion Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. |
||||||||||||||||
} | ||||||||||||||||
lineageFile.Dependencies = append(lineageFile.Dependencies, &coordinatorpb.CollectionVersionDependency{ | ||||||||||||||||
SourceCollectionId: sourceCollectionIDStr, | ||||||||||||||||
SourceCollectionVersion: uint64(sourceCollection.Version), | ||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[BestPractice]
The error name
ErrCollectionTooManyFork
doesn't follow the common Go naming convention for error variables, which typically use plural form for collections. Consider renaming it toErrCollectionTooManyForks
for consistency and clarity.