@@ -58,7 +58,7 @@ func (r *LLMProviderTemplateRepo) Create(t *model.LLMProviderTemplate) error {
5858 t .CreatedAt = time .Now ()
5959 t .UpdatedAt = time .Now ()
6060
61- configJSON , _ := json .Marshal (& llmProviderTemplateConfig {
61+ configJSON , err := json .Marshal (& llmProviderTemplateConfig {
6262 Metadata : t .Metadata ,
6363 PromptTokens : t .PromptTokens ,
6464 CompletionTokens : t .CompletionTokens ,
@@ -67,6 +67,9 @@ func (r *LLMProviderTemplateRepo) Create(t *model.LLMProviderTemplate) error {
6767 RequestModel : t .RequestModel ,
6868 ResponseModel : t .ResponseModel ,
6969 })
70+ if err != nil {
71+ return err
72+ }
7073
7174 query := `
7275 INSERT INTO llm_provider_templates (
@@ -164,7 +167,7 @@ func (r *LLMProviderTemplateRepo) List(orgUUID string, limit, offset int) ([]*mo
164167func (r * LLMProviderTemplateRepo ) Update (t * model.LLMProviderTemplate ) error {
165168 t .UpdatedAt = time .Now ()
166169
167- configJSON , _ := json .Marshal (& llmProviderTemplateConfig {
170+ configJSON , err := json .Marshal (& llmProviderTemplateConfig {
168171 Metadata : t .Metadata ,
169172 PromptTokens : t .PromptTokens ,
170173 CompletionTokens : t .CompletionTokens ,
@@ -173,6 +176,9 @@ func (r *LLMProviderTemplateRepo) Update(t *model.LLMProviderTemplate) error {
173176 RequestModel : t .RequestModel ,
174177 ResponseModel : t .ResponseModel ,
175178 })
179+ if err != nil {
180+ return err
181+ }
176182
177183 query := `
178184 UPDATE llm_provider_templates
@@ -250,11 +256,17 @@ func (r *LLMProviderRepo) Create(p *model.LLMProvider) error {
250256 p .CreatedAt = time .Now ()
251257 p .UpdatedAt = time .Now ()
252258
253- accessControlJSON , _ := json .Marshal (p .AccessControl )
259+ accessControlJSON , err := json .Marshal (p .AccessControl )
260+ if err != nil {
261+ return err
262+ }
254263 policiesColumn := ""
255264 var upstreamAuthJSON []byte
256265 if p .UpstreamAuth != nil {
257- upstreamAuthJSON , _ = json .Marshal (p .UpstreamAuth )
266+ upstreamAuthJSON , err = json .Marshal (p .UpstreamAuth )
267+ if err != nil {
268+ return err
269+ }
258270 }
259271
260272 query := `
@@ -393,11 +405,17 @@ func (r *LLMProviderRepo) Count(orgUUID string) (int, error) {
393405func (r * LLMProviderRepo ) Update (p * model.LLMProvider ) error {
394406 p .UpdatedAt = time .Now ()
395407
396- accessControlJSON , _ := json .Marshal (p .AccessControl )
408+ accessControlJSON , err := json .Marshal (p .AccessControl )
409+ if err != nil {
410+ return err
411+ }
397412 policiesColumn := ""
398413 var upstreamAuthJSON []byte
399414 if p .UpstreamAuth != nil {
400- upstreamAuthJSON , _ = json .Marshal (p .UpstreamAuth )
415+ upstreamAuthJSON , err = json .Marshal (p .UpstreamAuth )
416+ if err != nil {
417+ return err
418+ }
401419 }
402420
403421 query := `
@@ -494,7 +512,10 @@ func (r *LLMProxyRepo) Create(p *model.LLMProxy) error {
494512 p .CreatedAt = time .Now ()
495513 p .UpdatedAt = time .Now ()
496514
497- accessControlJSON , _ := json .Marshal (p .AccessControl )
515+ accessControlJSON , err := json .Marshal (p .AccessControl )
516+ if err != nil {
517+ return err
518+ }
498519 policiesColumn := ""
499520
500521 query := `
@@ -721,7 +742,10 @@ func (r *LLMProxyRepo) CountByProvider(orgUUID, providerID string) (int, error)
721742func (r * LLMProxyRepo ) Update (p * model.LLMProxy ) error {
722743 p .UpdatedAt = time .Now ()
723744
724- accessControlJSON , _ := json .Marshal (p .AccessControl )
745+ accessControlJSON , err := json .Marshal (p .AccessControl )
746+ if err != nil {
747+ return err
748+ }
725749 policiesColumn := ""
726750
727751 query := `
@@ -810,7 +834,10 @@ func (r *LLMProviderRepo) replaceProviderPolicies(orgUUID, providerHandle string
810834 VALUES (?, ?, ?, ?, ?, ?)
811835 `
812836 for _ , p := range policies {
813- pathsJSON , _ := json .Marshal (p .Paths )
837+ pathsJSON , err := json .Marshal (p .Paths )
838+ if err != nil {
839+ return err
840+ }
814841 if _ , err := r .db .Exec (query , orgUUID , "provider" , providerHandle , p .Name , p .Version , string (pathsJSON )); err != nil {
815842 return err
816843 }
@@ -830,7 +857,10 @@ func (r *LLMProviderRepo) replaceProviderPoliciesTx(tx *sql.Tx, orgUUID, provide
830857 VALUES (?, ?, ?, ?, ?, ?)
831858 `
832859 for _ , p := range policies {
833- pathsJSON , _ := json .Marshal (p .Paths )
860+ pathsJSON , err := json .Marshal (p .Paths )
861+ if err != nil {
862+ return err
863+ }
834864 if _ , err := tx .Exec (query , orgUUID , "provider" , providerHandle , p .Name , p .Version , string (pathsJSON )); err != nil {
835865 return err
836866 }
@@ -864,7 +894,10 @@ func (r *LLMProxyRepo) replaceProxyPolicies(orgUUID, proxyHandle string, policie
864894 VALUES (?, ?, ?, ?, ?, ?)
865895 `
866896 for _ , p := range policies {
867- pathsJSON , _ := json .Marshal (p .Paths )
897+ pathsJSON , err := json .Marshal (p .Paths )
898+ if err != nil {
899+ return err
900+ }
868901 if _ , err := r .db .Exec (query , orgUUID , "proxy" , proxyHandle , p .Name , p .Version , string (pathsJSON )); err != nil {
869902 return err
870903 }
@@ -884,7 +917,10 @@ func (r *LLMProxyRepo) replaceProxyPoliciesTx(tx *sql.Tx, orgUUID, proxyHandle s
884917 VALUES (?, ?, ?, ?, ?, ?)
885918 `
886919 for _ , p := range policies {
887- pathsJSON , _ := json .Marshal (p .Paths )
920+ pathsJSON , err := json .Marshal (p .Paths )
921+ if err != nil {
922+ return err
923+ }
888924 if _ , err := tx .Exec (query , orgUUID , "proxy" , proxyHandle , p .Name , p .Version , string (pathsJSON )); err != nil {
889925 return err
890926 }
0 commit comments