From b4ee1c58b5abcc85cc97bc24b54c919bd7605e88 Mon Sep 17 00:00:00 2001 From: Gabriel Hernandez Date: Tue, 8 Aug 2023 13:30:29 +0100 Subject: [PATCH] update OSversion service method to not search on for `no team` (#13127) relates to #12986 This is a fix for a case where the `os_versions` endpoint was returning a 404 when searching for `no teams`. # Checklist for submitter - [x] Changes file added for user-visible changes in `changes/` or `orbit/changes/`. See [Changes files](https://fleetdm.com/docs/contributing/committing-changes#changes-files) for more information. - [x] Manual QA for all new/changed functionality --- changes/issue-12986-fix-no-teams-error | 1 + server/service/hosts.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changes/issue-12986-fix-no-teams-error diff --git a/changes/issue-12986-fix-no-teams-error b/changes/issue-12986-fix-no-teams-error new file mode 100644 index 0000000000..46b788a933 --- /dev/null +++ b/changes/issue-12986-fix-no-teams-error @@ -0,0 +1 @@ +- fix bug where os_version enpoint returned 404 for `no teams` on controls page diff --git a/server/service/hosts.go b/server/service/hosts.go index 47643f8335..93d30e0da8 100644 --- a/server/service/hosts.go +++ b/server/service/hosts.go @@ -1496,7 +1496,7 @@ func (svc *Service) OSVersions(ctx context.Context, teamID *uint, platform *stri osVersions, err := svc.ds.OSVersions(ctx, teamID, platform, name, version) if err != nil && fleet.IsNotFound(err) { // differentiate case where team was added after UpdateOSVersions last ran - if teamID != nil { + if teamID != nil && *teamID > 0 { // most of the time, team should exist so checking here saves unnecessary db calls _, err := svc.ds.Team(ctx, *teamID) if err != nil {