Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: error when graph token is not set when cache warmup is enabled #1554

Merged
merged 2 commits into from
Jan 31, 2025
Merged
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 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