fix: harden profile imports and release dependencies

This commit is contained in:
Andy Dixon
2026-06-15 19:39:16 +01:00
parent b2fc84846c
commit 9bbd9ceccf
20 changed files with 1493 additions and 135 deletions
+11 -3
View File
@@ -363,13 +363,23 @@ func (s *Store) ExportProfiles(includeSecrets bool) ([]byte, error) {
// and "duplicate" creates new entries with fresh IDs. Returns the number of
// profiles imported.
func (s *Store) ImportProfiles(data []byte, strategy string) (int, error) {
switch strategy {
case "skip", "overwrite", "duplicate":
default:
return 0, fmt.Errorf("storage: unknown import strategy %q", strategy)
}
var profiles []*models.Profile
if err := json.Unmarshal(data, &profiles); err != nil {
return 0, fmt.Errorf("storage: invalid import data: %w", err)
}
imported := 0
for _, p := range profiles {
for i, p := range profiles {
if p == nil {
return imported, fmt.Errorf("storage: import profile entry %d is null", i)
}
existing, _ := s.GetProfile(p.ID)
switch strategy {
@@ -391,8 +401,6 @@ func (s *Store) ImportProfiles(data []byte, strategy string) (int, error) {
p.CreatedAt = time.Now()
p.UpdatedAt = time.Now()
}
default:
return 0, fmt.Errorf("storage: unknown import strategy %q", strategy)
}
if err := s.CreateProfile(p); err != nil {