@@ -45,9 +45,9 @@ const (
45
45
urlPathTemplate = "/namespaces/%s/workflows/%s/%s/history"
46
46
47
47
linkWorkflowEventReferenceTypeKey = "referenceType"
48
- linkEventReferenceEventIDKey = "eventID"
49
- linkEventReferenceEventTypeKey = "eventType"
50
- linkEventReferenceRequestIDKey = "requestID"
48
+ linkEventIDKey = "eventID"
49
+ linkEventTypeKey = "eventType"
50
+ linkRequestIDKey = "requestID"
51
51
)
52
52
53
53
var (
@@ -142,7 +142,10 @@ func ConvertNexusLinkToLinkWorkflowEvent(link nexus.Link) (*commonpb.Link_Workfl
142
142
EventRef : eventRef ,
143
143
}
144
144
case requestIDReferenceType :
145
- requestIDRef := convertURLQueryToLinkWorkflowEventRequestIdReference (link .URL .Query ())
145
+ requestIDRef , err := convertURLQueryToLinkWorkflowEventRequestIdReference (link .URL .Query ())
146
+ if err != nil {
147
+ return nil , fmt .Errorf ("failed to parse link to Link_WorkflowEvent: %w" , err )
148
+ }
146
149
we .Reference = & commonpb.Link_WorkflowEvent_RequestIdRef {
147
150
RequestIdRef : requestIDRef ,
148
151
}
@@ -160,23 +163,23 @@ func convertLinkWorkflowEventEventReferenceToURLQuery(eventRef *commonpb.Link_Wo
160
163
values := url.Values {}
161
164
values .Set (linkWorkflowEventReferenceTypeKey , eventReferenceType )
162
165
if eventRef .GetEventId () > 0 {
163
- values .Set (linkEventReferenceEventIDKey , strconv .FormatInt (eventRef .GetEventId (), 10 ))
166
+ values .Set (linkEventIDKey , strconv .FormatInt (eventRef .GetEventId (), 10 ))
164
167
}
165
- values .Set (linkEventReferenceEventTypeKey , enumspb .EventType_name [int32 (eventRef .GetEventType ())])
168
+ values .Set (linkEventTypeKey , enumspb .EventType_name [int32 (eventRef .GetEventType ())])
166
169
return values .Encode ()
167
170
}
168
171
169
172
func convertURLQueryToLinkWorkflowEventEventReference (queryValues url.Values ) (* commonpb.Link_WorkflowEvent_EventReference , error ) {
170
173
var err error
171
174
eventRef := & commonpb.Link_WorkflowEvent_EventReference {}
172
- eventIDValue := queryValues .Get (linkEventReferenceEventIDKey )
175
+ eventIDValue := queryValues .Get (linkEventIDKey )
173
176
if eventIDValue != "" {
174
- eventRef .EventId , err = strconv .ParseInt (queryValues .Get (linkEventReferenceEventIDKey ), 10 , 64 )
177
+ eventRef .EventId , err = strconv .ParseInt (queryValues .Get (linkEventIDKey ), 10 , 64 )
175
178
if err != nil {
176
179
return nil , err
177
180
}
178
181
}
179
- eventRef .EventType , err = enumspb .EventTypeFromString (queryValues .Get (linkEventReferenceEventTypeKey ))
182
+ eventRef .EventType , err = enumspb .EventTypeFromString (queryValues .Get (linkEventTypeKey ))
180
183
if err != nil {
181
184
return nil , err
182
185
}
@@ -186,12 +189,19 @@ func convertURLQueryToLinkWorkflowEventEventReference(queryValues url.Values) (*
186
189
func convertLinkWorkflowEventRequestIdReferenceToURLQuery (requestIDRef * commonpb.Link_WorkflowEvent_RequestIdReference ) string {
187
190
values := url.Values {}
188
191
values .Set (linkWorkflowEventReferenceTypeKey , requestIDReferenceType )
189
- values .Set (linkEventReferenceRequestIDKey , requestIDRef .GetRequestId ())
192
+ values .Set (linkRequestIDKey , requestIDRef .GetRequestId ())
193
+ values .Set (linkEventTypeKey , enumspb .EventType_name [int32 (requestIDRef .GetEventType ())])
190
194
return values .Encode ()
191
195
}
192
196
193
- func convertURLQueryToLinkWorkflowEventRequestIdReference (queryValues url.Values ) * commonpb.Link_WorkflowEvent_RequestIdReference {
194
- return & commonpb.Link_WorkflowEvent_RequestIdReference {
195
- RequestId : queryValues .Get (linkEventReferenceRequestIDKey ),
197
+ func convertURLQueryToLinkWorkflowEventRequestIdReference (queryValues url.Values ) (* commonpb.Link_WorkflowEvent_RequestIdReference , error ) {
198
+ var err error
199
+ requestIDRef := & commonpb.Link_WorkflowEvent_RequestIdReference {
200
+ RequestId : queryValues .Get (linkRequestIDKey ),
201
+ }
202
+ requestIDRef .EventType , err = enumspb .EventTypeFromString (queryValues .Get (linkEventTypeKey ))
203
+ if err != nil {
204
+ return nil , err
196
205
}
206
+ return requestIDRef , nil
197
207
}
0 commit comments