You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: stacktraces.go
    path of file: ./repos/highlight/backend/store
    
    the code of the file until where you have to start completion: package store

import (
	"context"
	"encoding/base64"
	"encoding/json"
	"fmt"
	"math"
	"regexp"
	"strings"
	"time"

	"github.com/pkg/errors"

	"github.com/aws/smithy-go/ptr"
	log "github.com/sirupsen/logrus"

	"github.com/highlight-run/highlight/backend/integrations/github"
	"github.com/highlight-run/highlight/backend/model"
	privateModel "github.com/highlight-run/highlight/backend/private-graph/graph/model"
	"github.com/highlight-run/highlight/backend/redis"
	"github.com/highlight-run/highlight/backend/stacktraces"
)

const GITHUB_ERROR_CONTEXT_LINES = 5
const MAX_ERROR_KILLSWITCH = 5

func (store *Store) GitHubFilePath(ctx context.Context, fileName string, buildPrefix *string, gitHubPrefix *string) string {
	if buildPrefix != nil && gitHubPrefix != nil {
		return strings.Replace(fileName, *buildPrefix, *gitHubPrefix, 1)
	} else if buildPrefix != nil {
		return strings.Replace(fileName, *buildPrefix, "", 1)
	} else if gitHubPrefix != nil {
		return *gitHubPrefix + fileName
	}

	return fileName
}

func (store *Store) ExpandedStackTrace(ctx context.Context, lines []string, lineNumber int) (*string, *string, *string, error) {
	if lineNumber > len(lines) || lineNumber <= 0 {
		return nil, nil, nil, errors.New("Invalid line number")
	}

	minLine := int(math.Max(1, float64(lineNumber-GITHUB_ERROR_CONTEXT_LINES)))
	maxLine := int(math.Min(float64(len(lines)), float64(lineNumber+GITHUB_ERROR_CONTEXT_LINES)))
	renderedLines := lines[minLine-1 : maxLine]

	var lineContent, beforeContent, afterContent string
	for idx, line := range renderedLines {
		currentLine := idx + minLine

		if currentLine == lineNumber {
			lineContent = line
		} else if currentLine < lineNumber {
			beforeContent = beforeContent + "\n" + line
		} els
    
func (store *Store) GitHubEnhancedStackTrace(ctx context.Context, stackTrace []*privateModel.ErrorTrace, workspace *model.Workspace, project *model.Project, errorObj *model.ErrorObject, validateService *model.Service) ([]*privateModel.ErrorTrace, error) {
	if errorObj.ServiceName == "" {
		return nil, nil
	}

	var service *model.Service
	var err error
	if validateService == nil {
		service, err = store.FindService(ctx, project.ID, errorObj.ServiceName)
		if err != nil || service == nil || service.GithubRepoPath == nil || service.Status != "healthy" {
			return nil, err
		}
	} else {
		service = validateService
	}

	gitHubAccessToken, err := store.integrationsClient.GetWorkspaceAccessToken(ctx, workspace, privateModel.IntegrationTypeGitHub)
	if err != nil || gitHubAccessToken == nil {
		return nil, err
	}

	client, err := github.NewClient(ctx, *gitHubAccessToken, store.redis)
	if err != nil {
		return nil, err
	}

	validServiceVersion, err := store.GitHubGitSHA(ctx, *service.GithubRepoPath, errorObj.ServiceVersion, client)
	if err != nil {
		return nil, err
	}

	cfg, err := store.GetSystemConfiguration(ctx)
	if err != nil {
		return nil, err
	}

	newMappedStackTrace := []*privateModel.ErrorTrace{}
	enhanceable := false
	failedAllEnhancements := true

	for _, trace := range stackTrace {
		enhancedTrace, fileEnhancable, fileEnhanced := store.EnhanceTrace(ctx, trace, service, *validServiceVersion, cfg.IgnoredFiles, client)

		newMappedStackTrace = append(newMappedStackTrace, enhancedTrace)
		enhanceable = enhanceable || fileEnhancable
		failedAllEnhancements = failedAllEnhancements && !fileEnhanced
	}

	if enhanceable && failedAllEnhancements {
		errorCount, _ := store.redis.IncrementServiceErrorCount(ctx, service.ID)
		if errorCount >= MAX_ERROR_KILLSWITCH {
			_ = store.UpdateServiceErrorState(ctx, service.ID, []string{"Too many errors enhancing errors - Check service configuration."})
		} else {
			_, _ = store.redis.ResetServiceErrorCount(ctx, service.ID)
		}
	}

	return newMappedStackTrace, nil
}