@@ -2217,6 +2217,11 @@ func (bifrost *Bifrost) handleRequest(ctx context.Context, req *schemas.BifrostR
22172217
22182218 // Try the primary provider first
22192219 ctx = context .WithValue (ctx , schemas .BifrostContextKeyFallbackIndex , 0 )
2220+ // Ensure request ID is set in context before PreHooks
2221+ if _ , ok := ctx .Value (schemas .BifrostContextKeyRequestID ).(string ); ! ok {
2222+ requestID := uuid .New ().String ()
2223+ ctx = context .WithValue (ctx , schemas .BifrostContextKeyRequestID , requestID )
2224+ }
22202225 primaryResult , primaryErr := bifrost .tryRequest (ctx , req )
22212226 if primaryErr != nil {
22222227 if primaryErr .Error != nil {
@@ -2310,6 +2315,11 @@ func (bifrost *Bifrost) handleStreamRequest(ctx context.Context, req *schemas.Bi
23102315
23112316 // Try the primary provider first
23122317 ctx = context .WithValue (ctx , schemas .BifrostContextKeyFallbackIndex , 0 )
2318+ // Ensure request ID is set in context before PreHooks
2319+ if _ , ok := ctx .Value (schemas .BifrostContextKeyRequestID ).(string ); ! ok {
2320+ requestID := uuid .New ().String ()
2321+ ctx = context .WithValue (ctx , schemas .BifrostContextKeyRequestID , requestID )
2322+ }
23132323 primaryResult , primaryErr := bifrost .tryStreamRequest (ctx , req )
23142324
23152325 // Check if we should proceed with fallbacks
0 commit comments