Skip to content

Commit

Permalink
fix: error when graph token is not set when cache warmup is enabled (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
StarpTech authored Jan 31, 2025
1 parent 92b69a3 commit fea311f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions router/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ func Main() {

result, err := config.LoadConfig(*configPathFlag, *overrideEnvFlag)
if err != nil {
log.Fatal("Could not load config", zap.Error(err))
log.Fatalf("Could not load config: %s", err)
}

logLevel, err := logging.ZapLogLevelFromString(result.Config.LogLevel)
if err != nil {
log.Fatal("Could not parse log level", zap.Error(err))
log.Fatalf("Could not parse log level: %s", err)
}

logger := logging.New(!result.Config.JSONLog, result.Config.DevelopmentMode, logLevel).
Expand Down
5 changes: 5 additions & 0 deletions router/core/graph_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,11 @@ func (s *graphServer) buildGraphMux(ctx context.Context,
operationPlanner := NewOperationPlanner(executor, gm.planCache)

if s.Config.cacheWarmup != nil && s.Config.cacheWarmup.Enabled {

if s.graphApiToken == "" {
return nil, fmt.Errorf("graph token is required for cache warmup in order to communicate with the CDN")
}

processor := NewCacheWarmupPlanningProcessor(&CacheWarmupPlanningProcessorOptions{
OperationProcessor: operationProcessor,
OperationPlanner: operationPlanner,
Expand Down
2 changes: 1 addition & 1 deletion router/internal/jwt/claims.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func ExtractFederatedGraphTokenClaims(token string) (*FederatedGraphTokenClaims,

_, _, err := jwtParser.ParseUnverified(token, claims)
if err != nil {
return nil, fmt.Errorf("invalid token %w", err)
return nil, fmt.Errorf("invalid token: %w", err)
}

federatedGraphIDValue := claims[FederatedGraphIDClaim]
Expand Down

0 comments on commit fea311f

Please sign in to comment.