-
Notifications
You must be signed in to change notification settings - Fork 3.3k
fix: replace panic with error handling in template loader (#6674) #7107
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
Closed
+26
−16
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,7 +71,7 @@ func BenchmarkLoadTemplates(b *testing.B) { | |
| b.ReportAllocs() | ||
|
|
||
| for b.Loop() { | ||
| _ = store.LoadTemplates([]string{config.DefaultConfig.TemplatesDirectory}) | ||
| _, _ = store.LoadTemplates([]string{config.DefaultConfig.TemplatesDirectory}) | ||
|
Contributor
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. Don’t drop At Lines 74/92/110/128/146/164/184, silently discarding errors can benchmark an error path and mask loader regressions. Suggested pattern (apply to each benchmark loop)- for b.Loop() {
- _, _ = store.LoadTemplates([]string{config.DefaultConfig.TemplatesDirectory})
- }
+ for b.Loop() {
+ if _, err := store.LoadTemplates([]string{config.DefaultConfig.TemplatesDirectory}); err != nil {
+ b.Fatalf("could not load templates: %s", err)
+ }
+ }Also applies to: 92-92, 110-110, 128-128, 146-146, 164-164, 184-184 🤖 Prompt for AI Agents |
||
| } | ||
| }) | ||
|
|
||
|
|
@@ -89,7 +89,7 @@ func BenchmarkLoadTemplates(b *testing.B) { | |
| b.ReportAllocs() | ||
|
|
||
| for b.Loop() { | ||
| _ = store.LoadTemplates([]string{config.DefaultConfig.TemplatesDirectory}) | ||
| _, _ = store.LoadTemplates([]string{config.DefaultConfig.TemplatesDirectory}) | ||
| } | ||
| }) | ||
|
|
||
|
|
@@ -107,7 +107,7 @@ func BenchmarkLoadTemplates(b *testing.B) { | |
| b.ReportAllocs() | ||
|
|
||
| for b.Loop() { | ||
| _ = store.LoadTemplates([]string{config.DefaultConfig.TemplatesDirectory}) | ||
| _, _ = store.LoadTemplates([]string{config.DefaultConfig.TemplatesDirectory}) | ||
| } | ||
| }) | ||
|
|
||
|
|
@@ -125,7 +125,7 @@ func BenchmarkLoadTemplates(b *testing.B) { | |
| b.ReportAllocs() | ||
|
|
||
| for b.Loop() { | ||
| _ = store.LoadTemplates([]string{config.DefaultConfig.TemplatesDirectory}) | ||
| _, _ = store.LoadTemplates([]string{config.DefaultConfig.TemplatesDirectory}) | ||
| } | ||
| }) | ||
|
|
||
|
|
@@ -143,7 +143,7 @@ func BenchmarkLoadTemplates(b *testing.B) { | |
| b.ReportAllocs() | ||
|
|
||
| for b.Loop() { | ||
| _ = store.LoadTemplates([]string{config.DefaultConfig.TemplatesDirectory}) | ||
| _, _ = store.LoadTemplates([]string{config.DefaultConfig.TemplatesDirectory}) | ||
| } | ||
| }) | ||
|
|
||
|
|
@@ -161,7 +161,7 @@ func BenchmarkLoadTemplates(b *testing.B) { | |
| b.ReportAllocs() | ||
|
|
||
| for b.Loop() { | ||
| _ = store.LoadTemplates([]string{config.DefaultConfig.TemplatesDirectory}) | ||
| _, _ = store.LoadTemplates([]string{config.DefaultConfig.TemplatesDirectory}) | ||
| } | ||
| }) | ||
|
|
||
|
|
@@ -181,7 +181,7 @@ func BenchmarkLoadTemplates(b *testing.B) { | |
| b.ReportAllocs() | ||
|
|
||
| for b.Loop() { | ||
| _ = store.LoadTemplates([]string{config.DefaultConfig.TemplatesDirectory}) | ||
| _, _ = store.LoadTemplates([]string{config.DefaultConfig.TemplatesDirectory}) | ||
| } | ||
| }) | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Update method docs to describe the new error contract.
These APIs now return errors, but the comments still only describe successful behavior. Please document concrete failure modes (e.g., missing dialers / wait-group creation failure) so callers know what to handle.
Also applies to: 673-675
🤖 Prompt for AI Agents