2
2
3
3
from typing import ClassVar
4
4
5
+ import requests
5
6
from pydantic import Field
6
7
7
8
from codegen .extensions .linear .linear_client import LinearClient
@@ -97,7 +98,32 @@ def linear_get_issue_tool(client: LinearClient, issue_id: str) -> LinearIssueObs
97
98
issue_id = issue_id ,
98
99
issue_data = issue .dict (),
99
100
)
101
+ except requests .exceptions .RequestException as e :
102
+ # Network-related errors
103
+ return LinearIssueObservation (
104
+ status = "error" ,
105
+ error = f"Network error when fetching issue: { e !s} " ,
106
+ issue_id = issue_id ,
107
+ issue_data = {},
108
+ )
109
+ except ValueError as e :
110
+ # Input validation errors
111
+ return LinearIssueObservation (
112
+ status = "error" ,
113
+ error = f"Invalid input: { e !s} " ,
114
+ issue_id = issue_id ,
115
+ issue_data = {},
116
+ )
117
+ except KeyError as e :
118
+ # Missing data in response
119
+ return LinearIssueObservation (
120
+ status = "error" ,
121
+ error = f"Unexpected API response format: { e !s} " ,
122
+ issue_id = issue_id ,
123
+ issue_data = {},
124
+ )
100
125
except Exception as e :
126
+ # Catch-all for other errors
101
127
return LinearIssueObservation (
102
128
status = "error" ,
103
129
error = f"Failed to get issue: { e !s} " ,
@@ -115,7 +141,32 @@ def linear_get_issue_comments_tool(client: LinearClient, issue_id: str) -> Linea
115
141
issue_id = issue_id ,
116
142
comments = [comment .dict () for comment in comments ],
117
143
)
144
+ except requests .exceptions .RequestException as e :
145
+ # Network-related errors
146
+ return LinearCommentsObservation (
147
+ status = "error" ,
148
+ error = f"Network error when fetching comments: { e !s} " ,
149
+ issue_id = issue_id ,
150
+ comments = [],
151
+ )
152
+ except ValueError as e :
153
+ # Input validation errors
154
+ return LinearCommentsObservation (
155
+ status = "error" ,
156
+ error = f"Invalid input: { e !s} " ,
157
+ issue_id = issue_id ,
158
+ comments = [],
159
+ )
160
+ except KeyError as e :
161
+ # Missing data in response
162
+ return LinearCommentsObservation (
163
+ status = "error" ,
164
+ error = f"Unexpected API response format: { e !s} " ,
165
+ issue_id = issue_id ,
166
+ comments = [],
167
+ )
118
168
except Exception as e :
169
+ # Catch-all for other errors
119
170
return LinearCommentsObservation (
120
171
status = "error" ,
121
172
error = f"Failed to get issue comments: { e !s} " ,
@@ -133,7 +184,32 @@ def linear_comment_on_issue_tool(client: LinearClient, issue_id: str, body: str)
133
184
issue_id = issue_id ,
134
185
comment = comment ,
135
186
)
187
+ except requests .exceptions .RequestException as e :
188
+ # Network-related errors
189
+ return LinearCommentObservation (
190
+ status = "error" ,
191
+ error = f"Network error when adding comment: { e !s} " ,
192
+ issue_id = issue_id ,
193
+ comment = {},
194
+ )
195
+ except ValueError as e :
196
+ # Input validation errors
197
+ return LinearCommentObservation (
198
+ status = "error" ,
199
+ error = f"Invalid input: { e !s} " ,
200
+ issue_id = issue_id ,
201
+ comment = {},
202
+ )
203
+ except KeyError as e :
204
+ # Missing data in response
205
+ return LinearCommentObservation (
206
+ status = "error" ,
207
+ error = f"Unexpected API response format: { e !s} " ,
208
+ issue_id = issue_id ,
209
+ comment = {},
210
+ )
136
211
except Exception as e :
212
+ # Catch-all for other errors
137
213
return LinearCommentObservation (
138
214
status = "error" ,
139
215
error = f"Failed to comment on issue: { e !s} " ,
@@ -159,7 +235,35 @@ def linear_register_webhook_tool(
159
235
team_id = team_id ,
160
236
response = response ,
161
237
)
238
+ except requests .exceptions .RequestException as e :
239
+ # Network-related errors
240
+ return LinearWebhookObservation (
241
+ status = "error" ,
242
+ error = f"Network error when registering webhook: { e !s} " ,
243
+ webhook_url = webhook_url ,
244
+ team_id = team_id ,
245
+ response = {},
246
+ )
247
+ except ValueError as e :
248
+ # Input validation errors
249
+ return LinearWebhookObservation (
250
+ status = "error" ,
251
+ error = f"Invalid input: { e !s} " ,
252
+ webhook_url = webhook_url ,
253
+ team_id = team_id ,
254
+ response = {},
255
+ )
256
+ except KeyError as e :
257
+ # Missing data in response
258
+ return LinearWebhookObservation (
259
+ status = "error" ,
260
+ error = f"Unexpected API response format: { e !s} " ,
261
+ webhook_url = webhook_url ,
262
+ team_id = team_id ,
263
+ response = {},
264
+ )
162
265
except Exception as e :
266
+ # Catch-all for other errors
163
267
return LinearWebhookObservation (
164
268
status = "error" ,
165
269
error = f"Failed to register webhook: { e !s} " ,
@@ -178,7 +282,32 @@ def linear_search_issues_tool(client: LinearClient, query: str, limit: int = 10)
178
282
query = query ,
179
283
issues = [issue .dict () for issue in issues ],
180
284
)
285
+ except requests .exceptions .RequestException as e :
286
+ # Network-related errors
287
+ return LinearSearchObservation (
288
+ status = "error" ,
289
+ error = f"Network error when searching issues: { e !s} " ,
290
+ query = query ,
291
+ issues = [],
292
+ )
293
+ except ValueError as e :
294
+ # Input validation errors
295
+ return LinearSearchObservation (
296
+ status = "error" ,
297
+ error = f"Invalid input: { e !s} " ,
298
+ query = query ,
299
+ issues = [],
300
+ )
301
+ except KeyError as e :
302
+ # Missing data in response
303
+ return LinearSearchObservation (
304
+ status = "error" ,
305
+ error = f"Unexpected API response format: { e !s} " ,
306
+ query = query ,
307
+ issues = [],
308
+ )
181
309
except Exception as e :
310
+ # Catch-all for other errors
182
311
return LinearSearchObservation (
183
312
status = "error" ,
184
313
error = f"Failed to search issues: { e !s} " ,
@@ -197,7 +326,35 @@ def linear_create_issue_tool(client: LinearClient, title: str, description: str
197
326
team_id = team_id ,
198
327
issue_data = issue .dict (),
199
328
)
329
+ except requests .exceptions .RequestException as e :
330
+ # Network-related errors
331
+ return LinearCreateIssueObservation (
332
+ status = "error" ,
333
+ error = f"Network error when creating issue: { e !s} " ,
334
+ title = title ,
335
+ team_id = team_id ,
336
+ issue_data = {},
337
+ )
338
+ except ValueError as e :
339
+ # Input validation errors
340
+ return LinearCreateIssueObservation (
341
+ status = "error" ,
342
+ error = f"Invalid input: { e !s} " ,
343
+ title = title ,
344
+ team_id = team_id ,
345
+ issue_data = {},
346
+ )
347
+ except KeyError as e :
348
+ # Missing data in response
349
+ return LinearCreateIssueObservation (
350
+ status = "error" ,
351
+ error = f"Unexpected API response format: { e !s} " ,
352
+ title = title ,
353
+ team_id = team_id ,
354
+ issue_data = {},
355
+ )
200
356
except Exception as e :
357
+ # Catch-all for other errors
201
358
return LinearCreateIssueObservation (
202
359
status = "error" ,
203
360
error = f"Failed to create issue: { e !s} " ,
@@ -215,7 +372,29 @@ def linear_get_teams_tool(client: LinearClient) -> LinearTeamsObservation:
215
372
status = "success" ,
216
373
teams = [team .dict () for team in teams ],
217
374
)
375
+ except requests .exceptions .RequestException as e :
376
+ # Network-related errors
377
+ return LinearTeamsObservation (
378
+ status = "error" ,
379
+ error = f"Network error when fetching teams: { e !s} " ,
380
+ teams = [],
381
+ )
382
+ except ValueError as e :
383
+ # Input validation errors
384
+ return LinearTeamsObservation (
385
+ status = "error" ,
386
+ error = f"Invalid input: { e !s} " ,
387
+ teams = [],
388
+ )
389
+ except KeyError as e :
390
+ # Missing data in response
391
+ return LinearTeamsObservation (
392
+ status = "error" ,
393
+ error = f"Unexpected API response format: { e !s} " ,
394
+ teams = [],
395
+ )
218
396
except Exception as e :
397
+ # Catch-all for other errors
219
398
return LinearTeamsObservation (
220
399
status = "error" ,
221
400
error = f"Failed to get teams: { e !s} " ,
0 commit comments