Cherry pick: Fixed 500 and 402 on My Device page. (#41748) (#43497)

Cherrypicks https://github.com/fleetdm/fleet/pull/41748

Co-authored-by: Victor Lyuboslavsky <2685025+getvictor@users.noreply.github.com>
This commit is contained in:
Juan Fernandez 2026-04-13 17:19:05 -03:00 committed by GitHub
parent 127a07997e
commit 402f26e38d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 2 deletions

View file

@ -0,0 +1 @@
- Fixed a crash on the "My device" page for Fleet Free instances. The page returned a 402 error when the host was assigned to a team because the device endpoint called a premium-only API, and also crashed when accessing undefined policies data.

View file

@ -674,7 +674,7 @@ const DeviceUserPage = ({
);
}
const hasAnyCriticalFailingCAPolicy = host?.policies.some(
const hasAnyCriticalFailingCAPolicy = host?.policies?.some(
(p) => p.response === "fail" && p.conditional_access_enabled && p.critical
);

View file

@ -195,7 +195,12 @@ func getDeviceHostEndpoint(ctx context.Context, request interface{}, svc fleet.S
if resp.TeamID != nil {
// load the team to get the device's team's software inventory config.
tm, err := svc.GetTeam(ctx, *resp.TeamID)
if err != nil && !fleet.IsNotFound(err) {
if errors.Is(err, fleet.ErrMissingLicense) {
// Fleet Free does not support teams, so team-specific config
// (software inventory, conditional access, etc.) falls back to
// the global defaults set above.
tm = nil
} else if err != nil && !fleet.IsNotFound(err) {
return getDeviceHostResponse{Err: err}, nil
}
if tm != nil {