You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
-if m.User != nil && len(m.User.Members) > 0 {- projects = append(projects, m.User.Members[0].Project.Name)+if m.User != nil {+ for _, member := range m.User.Members {+ if member != nil && member.Project != nil {+ projects = append(projects, member.Project.Name)+ }+ }
}
Suggestion importance[1-10]: 8
__
Why: This suggestion enhances code safety by iterating over all elements in m.User.Members and adding a nil-check for member.Project before accessing its Name, preventing potential runtime panics and ensuring all project names are collected. The proposed change is directly derived from the diff context and improves functionality.
Why: The suggestion addresses a critical issue by checking the slice length before accessing m.User.Members[0], preventing a potential runtime panic. The improvement is both accurate and high impact.
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.
User description
issue: https://github.com/actiontech/sqle-ee/issues/2374#issuecomment-2915631300
Description
增加成员非空判断防止 nil panic
调整获取用户成员项目方式
Changes walkthrough 📝
convert.go
增加 nil 检查及简化成员项获取逻辑
internal/dms/storage/convert.go