-
Notifications
You must be signed in to change notification settings - Fork 269
Flow service context propagation and transection usage #1297
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |||||||||
| package application | ||||||||||
|
|
||||||||||
| import ( | ||||||||||
| "context" | ||||||||||
| "errors" | ||||||||||
| "slices" | ||||||||||
|
|
||||||||||
|
|
@@ -650,7 +651,7 @@ func (as *applicationService) DeleteApplication(appID string) *serviceerror.Serv | |||||||||
| // If the flow ID is not provided, it sets the default authentication flow ID. | ||||||||||
| func (as *applicationService) validateAuthFlowID(app *model.ApplicationDTO) *serviceerror.ServiceError { | ||||||||||
| if app.AuthFlowID != "" { | ||||||||||
| isValidFlow := as.flowMgtService.IsValidFlow(app.AuthFlowID) | ||||||||||
| isValidFlow := as.flowMgtService.IsValidFlow(context.TODO(), app.AuthFlowID) | ||||||||||
| if !isValidFlow { | ||||||||||
| return &ErrorInvalidAuthFlowID | ||||||||||
| } | ||||||||||
|
|
@@ -671,13 +672,13 @@ func (as *applicationService) validateRegistrationFlowID(app *model.ApplicationD | |||||||||
| logger := log.GetLogger().With(log.String(log.LoggerKeyComponentName, "ApplicationService")) | ||||||||||
|
|
||||||||||
| if app.RegistrationFlowID != "" { | ||||||||||
| isValidFlow := as.flowMgtService.IsValidFlow(app.RegistrationFlowID) | ||||||||||
| isValidFlow := as.flowMgtService.IsValidFlow(context.TODO(), app.RegistrationFlowID) | ||||||||||
| if !isValidFlow { | ||||||||||
| return &ErrorInvalidRegistrationFlowID | ||||||||||
| } | ||||||||||
| } else { | ||||||||||
| // Try to get the equivalent registration flow for the auth flow | ||||||||||
| authFlow, svcErr := as.flowMgtService.GetFlow(app.AuthFlowID) | ||||||||||
| authFlow, svcErr := as.flowMgtService.GetFlow(context.TODO(), app.AuthFlowID) | ||||||||||
| if svcErr != nil { | ||||||||||
| if svcErr.Type == serviceerror.ServerErrorType { | ||||||||||
| logger.Error("Error while retrieving auth flow definition", | ||||||||||
|
|
@@ -688,7 +689,7 @@ func (as *applicationService) validateRegistrationFlowID(app *model.ApplicationD | |||||||||
| } | ||||||||||
|
|
||||||||||
| registrationFlow, svcErr := as.flowMgtService.GetFlowByHandle( | ||||||||||
| authFlow.Handle, flowcommon.FlowTypeRegistration) | ||||||||||
| context.TODO(), authFlow.Handle, flowcommon.FlowTypeRegistration) | ||||||||||
|
Comment on lines
675
to
692
|
||||||||||
| if svcErr != nil { | ||||||||||
| if svcErr.Type == serviceerror.ServerErrorType { | ||||||||||
| logger.Error("Error while retrieving registration flow definition by handle", | ||||||||||
|
|
@@ -913,7 +914,7 @@ func (as *applicationService) getDefaultAuthFlowID() (string, *serviceerror.Serv | |||||||||
|
|
||||||||||
| defaultAuthFlowHandle := config.GetThunderRuntime().Config.Flow.DefaultAuthFlowHandle | ||||||||||
| defaultAuthFlow, svcErr := as.flowMgtService.GetFlowByHandle( | ||||||||||
| defaultAuthFlowHandle, flowcommon.FlowTypeAuthentication) | ||||||||||
| context.TODO(), defaultAuthFlowHandle, flowcommon.FlowTypeAuthentication) | ||||||||||
|
||||||||||
| context.TODO(), defaultAuthFlowHandle, flowcommon.FlowTypeAuthentication) | |
| context.Background(), defaultAuthFlowHandle, flowcommon.FlowTypeAuthentication) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its intentional as context propagation is being addressed service by service. In this PR we are focusing on the flow service.
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The usage of context.TODO() is not recommended here. Since this is being called from application service methods which don't currently have a context parameter, consider using context.Background() instead, or better yet, propagate context through the application service methods. context.TODO() is typically used as a placeholder during development when context propagation is not yet implemented, but this PR is specifically about adding context propagation.
| context.TODO(), defaultAuthFlowHandle, flowcommon.FlowTypeAuthentication) | |
| context.Background(), defaultAuthFlowHandle, flowcommon.FlowTypeAuthentication) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using context.TODO() is not recommended for production code. Since this function (validateAuthFlowID) is called from within request handlers that have access to request context, the context should be passed as a parameter through the call chain instead of using context.TODO(). This ensures proper request tracing, cancellation, and timeout propagation.