fix(hosts): assign group ids to imported hosts and repair empty ones

Host rows created from a legacy streamSettings.externalProxy during
inbound import got an empty group_id, and the one-time HostGroupIds
seeder had already been gated off, so the UI rendered them under a
synthetic fallback_<id> group the update/delete API could not resolve,
failing every edit with "host group not found".

Assign a real group id in externalProxyEntryToHost at creation, and
replace the seeder with backfillEmptyHostGroupIds, an idempotent
startup repair that runs on every boot so rows from older builds and
restored backups are healed too. Also rename the leaked internal
error "host group not found" to "host not found" since groups are not
a user-facing concept.
This commit is contained in:
Sanaei
2026-07-23 18:52:42 +02:00
parent 941c6116a9
commit 8ef2eec3d1
3 changed files with 62 additions and 29 deletions
+3 -3
View File
@@ -213,11 +213,11 @@ func (s *HostService) GetHostGroup(groupId string) (*entity.HostGroup, error) {
return nil, err
}
if len(hosts) == 0 {
return nil, common.NewError("host group not found")
return nil, common.NewError("host not found")
}
grouped := groupHosts(hosts)
if len(grouped) == 0 {
return nil, common.NewError("host group not found")
return nil, common.NewError("host not found")
}
return grouped[0], nil
}
@@ -253,7 +253,7 @@ func (s *HostService) UpdateHostGroup(groupId string, req *entity.HostGroup) ([]
return err
}
if count == 0 {
return common.NewError("host group not found")
return common.NewError("host not found")
}
if err := validateInboundsExist(tx, req.InboundIds); err != nil {
return err