It seems that the code sample doesn't show in our post, here is the code that we use to add the location data to the workout, where routeBuilder is of type HKWorkoutRouteBuilder:
let workoutRoute = try await routeBuilder.finishRoute(with: workout!, metadata: nil)