Skip to content
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

fix:k8sgpt serve panic- runtime error-invalid memory address or nil pointer dereference #1185

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/server/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package server

import (
"context"
json "encoding/json"
"encoding/json"

schemav1 "buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go/schema/v1"
"github.com/k8sgpt-ai/k8sgpt/pkg/analysis"
Expand Down Expand Up @@ -32,10 +32,10 @@ func (h *handler) Analyze(ctx context.Context, i *schemav1.AnalyzeRequest) (
false, // Interactive mode disabled in server mode
[]string{}, //TODO: add custom http headers in server mode
)
config.Context = ctx // Replace context for correct timeouts.
if err != nil {
return &schemav1.AnalyzeResponse{}, err
}
config.Context = ctx // Replace context for correct timeouts.
defer config.Close()

config.RunAnalysis()
Expand Down
6 changes: 5 additions & 1 deletion pkg/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package server

import (
"context"
`log`

schemav1 "buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go/schema/v1"
"github.com/k8sgpt-ai/k8sgpt/pkg/cache"
Expand All @@ -21,7 +22,10 @@ const (

func (h *handler) AddConfig(ctx context.Context, i *schemav1.AddConfigRequest) (*schemav1.AddConfigResponse, error,
) {

if i == nil {
log.Println("Error: AddConfigRequest is nil")
return nil, status.Error(codes.InvalidArgument, "AddConfigRequest is nil")
}
resp, err := h.syncIntegration(ctx, i)
if err != nil {
return resp, err
Expand Down
Loading