MM-38497: Fix Sentry crash in PostAction.Equals (#18571)
* MM-38497: Fix Sentry crash in PostAction.Equals We check for nil pointer before moving ahead. https://mattermost.atlassian.net/browse/MM-38497 ```release-note NONE ``` * Fix lint errors ```release-note NONE ``` * Update model/integration_action.go Co-authored-by: Claudio Costa <cstcld91@gmail.com> Co-authored-by: Claudio Costa <cstcld91@gmail.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
2a40a7d649
Коммит
208920b5e1
@@ -115,6 +115,14 @@ func (p *PostAction) Equals(input *PostAction) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Compare PostActionIntegration
|
// Compare PostActionIntegration
|
||||||
|
|
||||||
|
// If input is nil, then return true if original is also nil.
|
||||||
|
// Else return false.
|
||||||
|
if input.Integration == nil {
|
||||||
|
return p.Integration == nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Both are unequal and not nil.
|
||||||
if p.Integration.URL != input.Integration.URL {
|
if p.Integration.URL != input.Integration.URL {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,4 +142,16 @@ func TestPostActionIntegrationEquals(t *testing.T) {
|
|||||||
}
|
}
|
||||||
require.False(t, pa1.Equals(pa2))
|
require.False(t, pa1.Equals(pa2))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("nil check", func(t *testing.T) {
|
||||||
|
pa1 := &PostAction{
|
||||||
|
Integration: &PostActionIntegration{},
|
||||||
|
}
|
||||||
|
|
||||||
|
pa2 := &PostAction{
|
||||||
|
Integration: nil,
|
||||||
|
}
|
||||||
|
|
||||||
|
require.False(t, pa1.Equals(pa2))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user