Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
fix(dynamic): avoid panic on nil instance
Browse files Browse the repository at this point in the history
For some yet unknown reasons, some instances are returned as nil.

This commits adds a nil check to prevent that and logs a warning to help further debugging.

Fixes #380
  • Loading branch information
acouvreur committed Sep 11, 2024
1 parent f721a05 commit 2106528
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/http/routes/strategies.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,17 @@ func (s *ServeStrategy) ServeBlocking(c *gin.Context) {
}

func sessionStateToRenderOptionsInstanceState(sessionState *sessions.SessionState) (instances []theme.Instance) {
if sessionState == nil {
log.Warnf("sessionStateToRenderOptionsInstanceState: sessionState is nil")
return
}
sessionState.Instances.Range(func(key, value any) bool {
instances = append(instances, instanceStateToRenderOptionsRequestState(value.(sessions.InstanceState).Instance))
if value != nil {
instances = append(instances, instanceStateToRenderOptionsRequestState(value.(sessions.InstanceState).Instance))
} else {
log.Warnf("sessionStateToRenderOptionsInstanceState: sessionState instance is nil, key: %v", key)
}

return true
})

Expand Down

0 comments on commit 2106528

Please sign in to comment.