diff --git a/internal/api/vehicle_template_service.go b/internal/api/vehicle_template_service.go index 815d6fb..d24ecbc 100644 --- a/internal/api/vehicle_template_service.go +++ b/internal/api/vehicle_template_service.go @@ -2,6 +2,7 @@ package api import ( "context" + "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/internal/controllers/device_config_controller.go b/internal/controllers/device_config_controller.go index b38ce64..b51ef7d 100644 --- a/internal/controllers/device_config_controller.go +++ b/internal/controllers/device_config_controller.go @@ -5,11 +5,12 @@ import ( "encoding/binary" "encoding/json" "fmt" - "github.com/volatiletech/sqlboiler/v4/queries/qm" "io" "strings" "time" + "github.com/volatiletech/sqlboiler/v4/queries/qm" + "github.com/DIMO-Network/shared/db" "github.com/DIMO-Network/vehicle-signal-decoding/internal/core/queries" @@ -272,9 +273,9 @@ func (d *DeviceConfigController) GetDBCFileByTemplateName(c *fiber.Ctx) error { return fiber.NewError(fiber.StatusInternalServerError, err.Error()) } // string append each dbc file - var dbcFileStrings []string - for _, dbcFile := range dbcFiles { - dbcFileStrings = append(dbcFileStrings, dbcFile.DBCFile) + var dbcFileStrings = make([]string, len(dbcFiles)) + for i, dbcFile := range dbcFiles { + dbcFileStrings[i] = dbcFile.DBCFile } dbResult := strings.Join(dbcFileStrings, "\n") diff --git a/internal/core/queries/get_pid_config_all.go b/internal/core/queries/get_pid_config_all.go index 0876dfe..cf79c06 100644 --- a/internal/core/queries/get_pid_config_all.go +++ b/internal/core/queries/get_pid_config_all.go @@ -19,6 +19,9 @@ type GetPidsQueryRequest struct { // GetPidsByTemplate gets all pids in a template and their children from inherited parent templates func GetPidsByTemplate(ctx context.Context, dbs func() *db.ReaderWriter, request *GetPidsQueryRequest) (models.PidConfigSlice, *models.Template, error) { templateNames, template, err := GetAllParentTemplates(ctx, dbs, request.TemplateName) + if err != nil { + return nil, nil, err + } pidConfigs, err := models.PidConfigs( qm.WhereIn("template_name IN ?", ToAnySlice(templateNames)...),