Fix bug where str is added to cached_hostset list

The original code was appending a str to a list rather than either
appending it or adding it as a list of one element.  The code avoids
append to avoid unintentional side-effects.

Change-Id: I1466981f1d68f8dea3bbe32fdde6c4825056c0d0
Closes-Bug: #1927698
(cherry picked from commit e63c68d505)
This commit is contained in:
Alex Kavanagh 2021-05-07 12:13:29 +01:00
parent 3f3111b3b9
commit 2988a7f4a3
1 changed files with 4 additions and 1 deletions

View File

@ -1367,7 +1367,10 @@ def resolve_hosts_for(private_address, hostname):
if (not ch_ip.is_ipv6(private_address) and
hostname and
hostname not in cached_hostset):
return cached_hostset + hostname
hosts = cached_hostset + [hostname]
db.set(db_key, hosts)
db.flush()
return hosts
return cached_hostset
# Use a set to enforce uniqueness; order doesn't matter