Skip to content

Commit 27465fe

Browse files
committed
bug fix with missing early return statements fix #112
1 parent 9667989 commit 27465fe

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

proxy/proxymanager.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ func (pm *ProxyManager) proxyToUpstream(c *gin.Context) {
305305
processGroup, _, err := pm.swapProcessGroup(requestedModel)
306306
if err != nil {
307307
pm.sendErrorResponse(c, http.StatusInternalServerError, fmt.Sprintf("error swapping process group: %s", err.Error()))
308+
return
308309
}
309310

310311
// rewrite the path
@@ -347,11 +348,13 @@ func (pm *ProxyManager) proxyOAIHandler(c *gin.Context) {
347348
requestedModel := gjson.GetBytes(bodyBytes, "model").String()
348349
if requestedModel == "" {
349350
pm.sendErrorResponse(c, http.StatusBadRequest, "missing or invalid 'model' key")
351+
return
350352
}
351353

352354
processGroup, realModelName, err := pm.swapProcessGroup(requestedModel)
353355
if err != nil {
354356
pm.sendErrorResponse(c, http.StatusInternalServerError, fmt.Sprintf("error swapping process group: %s", err.Error()))
357+
return
355358
}
356359

357360
// issue #69 allow custom model names to be sent to upstream
@@ -373,6 +376,7 @@ func (pm *ProxyManager) proxyOAIHandler(c *gin.Context) {
373376
if err := processGroup.ProxyRequest(realModelName, c.Writer, c.Request); err != nil {
374377
pm.sendErrorResponse(c, http.StatusInternalServerError, fmt.Sprintf("error proxying request: %s", err.Error()))
375378
pm.proxyLogger.Errorf("Error Proxying Request for processGroup %s and model %s", processGroup.id, realModelName)
379+
return
376380
}
377381
}
378382

@@ -398,6 +402,7 @@ func (pm *ProxyManager) proxyOAIPostFormHandler(c *gin.Context) {
398402
processGroup, realModelName, err := pm.swapProcessGroup(requestedModel)
399403
if err != nil {
400404
pm.sendErrorResponse(c, http.StatusInternalServerError, fmt.Sprintf("error swapping process group: %s", err.Error()))
405+
return
401406
}
402407

403408
// Copy all form values
@@ -477,6 +482,7 @@ func (pm *ProxyManager) proxyOAIPostFormHandler(c *gin.Context) {
477482
if err := processGroup.ProxyRequest(realModelName, c.Writer, modifiedReq); err != nil {
478483
pm.sendErrorResponse(c, http.StatusInternalServerError, fmt.Sprintf("error proxying request: %s", err.Error()))
479484
pm.proxyLogger.Errorf("Error Proxying Request for processGroup %s and model %s", processGroup.id, realModelName)
485+
return
480486
}
481487
}
482488

0 commit comments

Comments
 (0)