Skip to content

Commit c36f076

Browse files
committed
fix(spp_api_v2_simulation): remove exception details from HTTP responses
Prevent internal exception messages from leaking to API callers via HTTPException detail strings. Full exception info is still logged via _logger.exception for server-side diagnosis.
1 parent da8244e commit c36f076

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

spp_api_v2_simulation/routers/comparison.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ async def create_comparison(
131131

132132
except HTTPException:
133133
raise
134-
except Exception as e:
134+
except Exception:
135135
_logger.exception("Failed to create comparison")
136136
raise HTTPException(
137137
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
138-
detail=f"Failed to create comparison: {str(e)}",
138+
detail="Failed to create comparison",
139139
) from None
140140

141141

@@ -172,9 +172,9 @@ async def get_comparison(
172172

173173
except HTTPException:
174174
raise
175-
except Exception as e:
175+
except Exception:
176176
_logger.exception("Failed to get comparison")
177177
raise HTTPException(
178178
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
179-
detail=f"Failed to get comparison: {str(e)}",
179+
detail="Failed to get comparison",
180180
) from None

spp_api_v2_simulation/routers/run.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,11 @@ async def list_runs(
195195
total_count=total_count,
196196
)
197197

198-
except Exception as e:
198+
except Exception:
199199
_logger.exception("Failed to list runs")
200200
raise HTTPException(
201201
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
202-
detail=f"Failed to list runs: {str(e)}",
202+
detail="Failed to list runs",
203203
) from None
204204

205205

@@ -237,9 +237,9 @@ async def get_run(
237237

238238
except HTTPException:
239239
raise
240-
except Exception as e:
240+
except Exception:
241241
_logger.exception("Failed to get run")
242242
raise HTTPException(
243243
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
244-
detail=f"Failed to get run: {str(e)}",
244+
detail="Failed to get run",
245245
) from None

spp_api_v2_simulation/routers/scenario.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ async def list_scenarios(
115115
total_count=total_count,
116116
)
117117

118-
except Exception as e:
118+
except Exception:
119119
_logger.exception("Failed to list scenarios")
120120
raise HTTPException(
121121
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
122-
detail=f"Failed to list scenarios: {str(e)}",
122+
detail="Failed to list scenarios",
123123
) from None
124124

125125

@@ -185,11 +185,11 @@ async def create_scenario(
185185

186186
return _scenario_to_response(scenario)
187187

188-
except Exception as e:
188+
except Exception:
189189
_logger.exception("Failed to create scenario")
190190
raise HTTPException(
191191
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
192-
detail=f"Failed to create scenario: {str(e)}",
192+
detail="Failed to create scenario",
193193
) from None
194194

195195

@@ -226,11 +226,11 @@ async def get_scenario(
226226

227227
except HTTPException:
228228
raise
229-
except Exception as e:
229+
except Exception:
230230
_logger.exception("Failed to get scenario")
231231
raise HTTPException(
232232
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
233-
detail=f"Failed to get scenario: {str(e)}",
233+
detail="Failed to get scenario",
234234
) from None
235235

236236

@@ -300,11 +300,11 @@ async def update_scenario(
300300

301301
except HTTPException:
302302
raise
303-
except Exception as e:
303+
except Exception:
304304
_logger.exception("Failed to update scenario")
305305
raise HTTPException(
306306
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
307-
detail=f"Failed to update scenario: {str(e)}",
307+
detail="Failed to update scenario",
308308
) from None
309309

310310

@@ -341,11 +341,11 @@ async def archive_scenario(
341341

342342
except HTTPException:
343343
raise
344-
except Exception as e:
344+
except Exception:
345345
_logger.exception("Failed to archive scenario")
346346
raise HTTPException(
347347
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
348-
detail=f"Failed to archive scenario: {str(e)}",
348+
detail="Failed to archive scenario",
349349
) from None
350350

351351

@@ -380,10 +380,11 @@ async def mark_scenario_ready(
380380

381381
try:
382382
scenario.action_set_ready()
383-
except Exception as e:
383+
except Exception:
384+
_logger.exception("Failed to mark scenario as ready")
384385
raise HTTPException(
385386
status_code=status.HTTP_400_BAD_REQUEST,
386-
detail=str(e),
387+
detail="Failed to mark scenario as ready",
387388
) from None
388389

389390
# Refresh to get updated state
@@ -393,11 +394,11 @@ async def mark_scenario_ready(
393394

394395
except HTTPException:
395396
raise
396-
except Exception as e:
397+
except Exception:
397398
_logger.exception("Failed to mark scenario as ready")
398399
raise HTTPException(
399400
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
400-
detail=f"Failed to mark scenario as ready: {str(e)}",
401+
detail="Failed to mark scenario as ready",
401402
) from None
402403

403404

@@ -451,11 +452,11 @@ async def run_simulation(
451452

452453
except HTTPException:
453454
raise
454-
except Exception as e:
455+
except Exception:
455456
_logger.exception("Failed to run simulation")
456457
raise HTTPException(
457458
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
458-
detail=f"Failed to run simulation: {str(e)}",
459+
detail="Failed to run simulation",
459460
) from None
460461

461462

@@ -552,11 +553,11 @@ async def convert_to_program(
552553

553554
except HTTPException:
554555
raise
555-
except Exception as e:
556+
except Exception:
556557
_logger.exception("Failed to convert scenario to program")
557558
raise HTTPException(
558559
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
559-
detail=f"Failed to convert scenario to program: {str(e)}",
560+
detail="Failed to convert scenario to program",
560561
) from None
561562

562563

0 commit comments

Comments
 (0)