-
Notifications
You must be signed in to change notification settings - Fork 3
Increase code-coverage to 90% #48
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
Conversation
…s for cmd, data, docker, logging, template, texteditor, version, and workflow packages
…implementations, modify item handling, update ktx constants, improve resource testing, enhance utils functionality, and update workflow implementation
…implementations, modify item handling, update ktx constants, improve resource testing, enhance utils functionality, and update workflow implementation
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.
Bug: Race Condition in Schema Version Retrieval
Replacing sync.Once with sync.Map in SchemaVersion() introduces a race condition. When UseLatest is true, concurrent calls to SchemaVersion() can cause multiple goroutines to simultaneously fetch the schema version via utils.GitHubReleaseFetcher(). This leads to redundant API calls, as the sync.Map caching mechanism does not guarantee single-execution initialization like sync.Once did.
pkg/schema/schema.go#L20-L42
Lines 20 to 42 in 1078d22
| // SchemaVersion(ctx) fetches and returns the schema version based on the cmd.Latest flag. | |
| func SchemaVersion(ctx context.Context) string { | |
| if UseLatest { // Reference the global Latest flag from cmd package | |
| // Try to get from cache first | |
| if cached, ok := versionCache.Load("version"); ok { | |
| return cached.(string) | |
| } | |
| // If not in cache, fetch it | |
| version, err := utils.GitHubReleaseFetcher(ctx, "kdeps/schema", "") | |
| if err != nil { | |
| fmt.Fprintf(os.Stderr, "Error: Unable to fetch the latest schema version for 'kdeps/schema': %v\n", err) | |
| exitFunc(1) | |
| } | |
| // Store in cache | |
| versionCache.Store("version", version) | |
| return version | |
| } | |
| // Use the specified version if not using the latest | |
| return specifiedVersion | |
| } |
Bug: Function Pointer Called Without Nil Check
The dr.LoadResourceFn function pointer is called without a nil check. If uninitialized, this will cause a runtime panic, which is inconsistent with other function pointers introduced in this change that include nil checks and fallbacks.
pkg/resolver/resource_http.go#L93-L94
kdeps/pkg/resolver/resource_http.go
Lines 93 to 94 in 1078d22
| res, err := dr.LoadResourceFn(dr.Context, pklPath, HTTPResource) |
pkg/resolver/resources.go#L100-L101
kdeps/pkg/resolver/resources.go
Lines 100 to 101 in 1078d22
| // Load the resource file | |
| res, err := dr.LoadResourceFn(dr.Context, file, Resource) |
Was this report helpful? Give feedback by reacting with 👍 or 👎
…bal timeout overrides; bump coverage
In this release, the goal it towards a high coverage score for higher robustness and producibility.