@@ -64,7 +64,18 @@ func (b *MarketoBulkUploader) Poll(pollInput common.AsyncPoll) common.PollStatus
64
64
HasFailed : true ,
65
65
}
66
66
}
67
- bodyBytes , transformerConnectionStatus := misc .HTTPCallWithRetryWithTimeout (b .transformUrl + b .pollUrl , payload , b .timeout )
67
+
68
+ pollURL , err := url .JoinPath (b .transformUrl , b .pollUrl )
69
+ if err != nil {
70
+ b .logger .Errorf ("Error in preparing poll url: %v" , err )
71
+ return common.PollStatusResponse {
72
+ StatusCode : 500 ,
73
+ HasFailed : true ,
74
+ Error : err .Error (),
75
+ }
76
+ }
77
+
78
+ bodyBytes , transformerConnectionStatus := misc .HTTPCallWithRetryWithTimeout (pollURL , payload , b .timeout )
68
79
if transformerConnectionStatus != 200 {
69
80
return common.PollStatusResponse {
70
81
StatusCode : transformerConnectionStatus ,
@@ -218,27 +229,24 @@ func extractJobStats(keyMap map[string]interface{}, importingJobIDs []int64, sta
218
229
219
230
func (b * MarketoBulkUploader ) Upload (asyncDestStruct * common.AsyncDestinationStruct ) common.AsyncUploadOutput {
220
231
destination := asyncDestStruct .Destination
221
- resolveURL := func (base , relative string ) string {
222
- baseURL , err := url .Parse (base )
223
- if err != nil {
224
- b .logger .Error ("Error in Parsing Base URL: %w" , err )
225
- }
226
- relURL , err := url .Parse (relative )
227
- if err != nil {
228
- b .logger .Error ("Error in Parsing Relative URL: %w" , err )
229
- }
230
- destURL := baseURL .ResolveReference (relURL ).String ()
231
- return destURL
232
- }
233
232
destinationID := destination .ID
234
- destinationUploadUrl := asyncDestStruct .DestinationUploadURL
235
- url := resolveURL (b .transformUrl , destinationUploadUrl )
236
233
filePath := asyncDestStruct .FileName
237
234
destConfig := destination .Config
238
235
destType := destination .DestinationDefinition .Name
239
236
failedJobIDs := asyncDestStruct .FailedJobIDs
240
237
importingJobIDs := asyncDestStruct .ImportingJobIDs
241
238
239
+ destinationUploadUrl := asyncDestStruct .DestinationUploadURL
240
+ uploadURL , err := url .JoinPath (b .transformUrl , destinationUploadUrl )
241
+ if err != nil {
242
+ return common.AsyncUploadOutput {
243
+ FailedJobIDs : append (failedJobIDs , importingJobIDs ... ),
244
+ FailedReason : "BRT: Failed to prepare upload url " + err .Error (),
245
+ FailedCount : len (failedJobIDs ) + len (importingJobIDs ),
246
+ DestinationID : destinationID ,
247
+ }
248
+ }
249
+
242
250
file , err := os .Open (filePath )
243
251
if err != nil {
244
252
panic ("BRT: Read File Failed" + err .Error ())
@@ -287,7 +295,7 @@ func (b *MarketoBulkUploader) Upload(asyncDestStruct *common.AsyncDestinationStr
287
295
startTime := time .Now ()
288
296
payloadSizeStat .Observe (float64 (len (payload )))
289
297
b .logger .Debugf ("[Async Destination Manager] File Upload Started for Dest Type %v" , destType )
290
- responseBody , statusCodeHTTP := misc .HTTPCallWithRetryWithTimeout (url , payload , config .GetDuration ("HttpClient.marketoBulkUpload.timeout" , 10 , time .Minute ))
298
+ responseBody , statusCodeHTTP := misc .HTTPCallWithRetryWithTimeout (uploadURL , payload , config .GetDuration ("HttpClient.marketoBulkUpload.timeout" , 10 , time .Minute ))
291
299
b .logger .Debugf ("[Async Destination Manager] File Upload Finished for Dest Type %v" , destType )
292
300
uploadTimeStat .Since (startTime )
293
301
var bodyBytes []byte
0 commit comments