@@ -393,6 +393,8 @@ func getMiddleware(cpm CustomProvidersManager, rm routeManager, pm PoliciesManag
393393 body , err := io .ReadAll (c .Request .Body )
394394 if err != nil {
395395 logError (logWithCid , "error when reading request body" , prod , err )
396+ JSON (c , http .StatusInternalServerError , "[BricksLLM] error reading request body" )
397+ c .Abort ()
396398 return
397399 }
398400
@@ -415,6 +417,8 @@ func getMiddleware(cpm CustomProvidersManager, rm routeManager, pm PoliciesManag
415417 err = json .Unmarshal (body , cr )
416418 if err != nil {
417419 logError (logWithCid , "error when unmarshalling anthropic completion request" , prod , err )
420+ JSON (c , http .StatusBadRequest , "[BricksLLM] error when unmarshalling anthropic completion request" )
421+ c .Abort ()
418422 return
419423 }
420424
@@ -440,6 +444,8 @@ func getMiddleware(cpm CustomProvidersManager, rm routeManager, pm PoliciesManag
440444 err = json .Unmarshal (body , cr )
441445 if err != nil {
442446 logError (logWithCid , "error when unmarshalling bedrock anthropic completion request" , prod , err )
447+ JSON (c , http .StatusBadRequest , "[BricksLLM] error when unmarshalling bedrock anthropic completion request" )
448+ c .Abort ()
443449 return
444450 }
445451
@@ -465,6 +471,8 @@ func getMiddleware(cpm CustomProvidersManager, rm routeManager, pm PoliciesManag
465471 err = json .Unmarshal (body , mr )
466472 if err != nil {
467473 logError (logWithCid , "error when unmarshalling anthropic messages request" , prod , err )
474+ JSON (c , http .StatusBadRequest , "[BricksLLM] error when unmarshalling anthropic messages request" )
475+ c .Abort ()
468476 return
469477 }
470478
@@ -488,6 +496,8 @@ func getMiddleware(cpm CustomProvidersManager, rm routeManager, pm PoliciesManag
488496 err = json .Unmarshal (body , mr )
489497 if err != nil {
490498 logError (logWithCid , "error when unmarshalling anthropic messages request" , prod , err )
499+ JSON (c , http .StatusBadRequest , "[BricksLLM] error when unmarshalling anthropic messages request" )
500+ c .Abort ()
491501 return
492502 }
493503
@@ -624,6 +634,8 @@ func getMiddleware(cpm CustomProvidersManager, rm routeManager, pm PoliciesManag
624634 err = json .Unmarshal (body , ccr )
625635 if err != nil {
626636 logError (logWithCid , "error when unmarshalling vllm chat completions request" , prod , err )
637+ JSON (c , http .StatusBadRequest , "[BricksLLM] error when unmarshalling vllm chat completions request" )
638+ c .Abort ()
627639 return
628640 }
629641
@@ -645,6 +657,8 @@ func getMiddleware(cpm CustomProvidersManager, rm routeManager, pm PoliciesManag
645657 err = json .Unmarshal (body , cr )
646658 if err != nil {
647659 logError (logWithCid , "error when unmarshalling vllm completions request" , prod , err )
660+ JSON (c , http .StatusBadRequest , "[BricksLLM] error when unmarshalling vllm completions request" )
661+ c .Abort ()
648662 return
649663 }
650664
@@ -666,6 +680,8 @@ func getMiddleware(cpm CustomProvidersManager, rm routeManager, pm PoliciesManag
666680 err = json .Unmarshal (body , ccr )
667681 if err != nil {
668682 logError (logWithCid , "error when unmarshalling deepinfra chat completions request" , prod , err )
683+ JSON (c , http .StatusBadRequest , "[BricksLLM] error when unmarshalling deepinfra chat completions request" )
684+ c .Abort ()
669685 return
670686 }
671687
@@ -686,6 +702,8 @@ func getMiddleware(cpm CustomProvidersManager, rm routeManager, pm PoliciesManag
686702 err = json .Unmarshal (body , cr )
687703 if err != nil {
688704 logError (logWithCid , "error when unmarshalling deepinfra completions request" , prod , err )
705+ JSON (c , http .StatusBadRequest , "[BricksLLM] error when unmarshalling deepinfra completions request" )
706+ c .Abort ()
689707 return
690708 }
691709
@@ -706,6 +724,8 @@ func getMiddleware(cpm CustomProvidersManager, rm routeManager, pm PoliciesManag
706724 err = json .Unmarshal (body , er )
707725 if err != nil {
708726 logError (logWithCid , "error when unmarshalling deepinfra embeddings request" , prod , err )
727+ JSON (c , http .StatusBadRequest , "[BricksLLM] error when unmarshalling deepinfra embeddings request" )
728+ c .Abort ()
709729 return
710730 }
711731
@@ -723,6 +743,8 @@ func getMiddleware(cpm CustomProvidersManager, rm routeManager, pm PoliciesManag
723743 err = json .Unmarshal (body , ccr )
724744 if err != nil {
725745 logError (logWithCid , "error when unmarshalling azure openai chat completion request" , prod , err )
746+ JSON (c , http .StatusBadRequest , "[BricksLLM] error when unmarshalling azure openai chat completion request" )
747+ c .Abort ()
726748 return
727749 }
728750
@@ -744,6 +766,8 @@ func getMiddleware(cpm CustomProvidersManager, rm routeManager, pm PoliciesManag
744766 err = json .Unmarshal (body , cr )
745767 if err != nil {
746768 logError (logWithCid , "error when unmarshalling azure openai completions request" , prod , err )
769+ JSON (c , http .StatusBadRequest , "[BricksLLM] error when unmarshalling azure openai completions request" )
770+ c .Abort ()
747771 return
748772 }
749773
@@ -765,6 +789,8 @@ func getMiddleware(cpm CustomProvidersManager, rm routeManager, pm PoliciesManag
765789 err = json .Unmarshal (body , er )
766790 if err != nil {
767791 logError (logWithCid , "error when unmarshalling azure openai embedding request" , prod , err )
792+ JSON (c , http .StatusBadRequest , "[BricksLLM] error when unmarshalling azure openai embedding request" )
793+ c .Abort ()
768794 return
769795 }
770796
@@ -789,6 +815,8 @@ func getMiddleware(cpm CustomProvidersManager, rm routeManager, pm PoliciesManag
789815 err = json .Unmarshal ([]byte (cleaned ), ccr )
790816 if err != nil {
791817 logError (logWithCid , "error when unmarshalling chat completion request" , prod , err )
818+ JSON (c , http .StatusBadRequest , "[BricksLLM] error when unmarshalling chat completion request" )
819+ c .Abort ()
792820 return
793821 }
794822
@@ -812,6 +840,8 @@ func getMiddleware(cpm CustomProvidersManager, rm routeManager, pm PoliciesManag
812840 err = json .Unmarshal (body , responsesReq )
813841 if err != nil {
814842 logError (logWithCid , "error when unmarshalling openai responses request" , prod , err )
843+ JSON (c , http .StatusBadRequest , "[BricksLLM] error when unmarshalling openai responses request" )
844+ c .Abort ()
815845 return
816846 }
817847
@@ -876,6 +906,8 @@ func getMiddleware(cpm CustomProvidersManager, rm routeManager, pm PoliciesManag
876906 err = json .Unmarshal (body , er )
877907 if err != nil {
878908 logError (logWithCid , "error when unmarshalling embedding request" , prod , err )
909+ JSON (c , http .StatusBadRequest , "[BricksLLM] error when unmarshalling embedding request" )
910+ c .Abort ()
879911 return
880912 }
881913
@@ -894,6 +926,8 @@ func getMiddleware(cpm CustomProvidersManager, rm routeManager, pm PoliciesManag
894926 err := json .Unmarshal (body , ir )
895927 if err != nil {
896928 logError (logWithCid , "error when unmarshalling create image request" , prod , err )
929+ JSON (c , http .StatusBadRequest , "[BricksLLM] error when unmarshalling create image request" )
930+ c .Abort ()
897931 return
898932 }
899933 enrichedEvent .Request = ir
@@ -913,6 +947,8 @@ func getMiddleware(cpm CustomProvidersManager, rm routeManager, pm PoliciesManag
913947 err := json .Unmarshal (body , ier )
914948 if err != nil {
915949 logError (logWithCid , "error when unmarshalling edit image request" , prod , err )
950+ JSON (c , http .StatusBadRequest , "[BricksLLM] error when unmarshalling edit image request" )
951+ c .Abort ()
916952 return
917953 }
918954 enrichedEvent .Request = ier
@@ -941,6 +977,8 @@ func getMiddleware(cpm CustomProvidersManager, rm routeManager, pm PoliciesManag
941977 err := json .Unmarshal (body , ir )
942978 if err != nil {
943979 logError (logWithCid , "error when unmarshalling image variations request" , prod , err )
980+ JSON (c , http .StatusBadRequest , "[BricksLLM] error when unmarshalling image variations request" )
981+ c .Abort ()
944982 return
945983 }
946984 enrichedEvent .Request = ir
@@ -968,6 +1006,8 @@ func getMiddleware(cpm CustomProvidersManager, rm routeManager, pm PoliciesManag
9681006 err := json .Unmarshal (body , sr )
9691007 if err != nil {
9701008 logError (logWithCid , "error when unmarshalling create speech request" , prod , err )
1009+ JSON (c , http .StatusBadRequest , "[BricksLLM] error when unmarshalling create speech request" )
1010+ c .Abort ()
9711011 return
9721012 }
9731013
0 commit comments