fleet/changes/fix-android-host-software-filter
W0lfbane ad7ea0aa7f
fix(android): remove tautological NCR filter in hostVPPInstalls (#42873)
## Problem

The `hostVPPInstalls` function in `server/datastore/mysql/software.go`
contains a SQL condition:

```sql
(hvsi.platform != 'android' OR ncr.id IS NULL) AND
```

This is a logical tautology — it **never filters any rows**:

- **Android rows**: `ncr.id` is always `NULL` because Android installs
use Google's Android Management API, not nanoMDM. The condition
evaluates to `(FALSE OR TRUE) = TRUE`.
- **Apple rows**: The first operand `hvsi.platform != 'android'` is
`TRUE`, so the whole expression is `TRUE` regardless of `ncr.id`.

The condition was likely added during early Android VPP support to guard
against unexpected NCR joins for Android. However, since
`nano_command_results` is only written by the nanoMDM Apple MDM storage
layer (`server/mdm/nanomdm/storage/mysql/queue.go:168`), the guard can
never trigger.

Elsewhere in the codebase, the canonical pattern for NCR filtering is:

```sql
-- vpp.go:248, software_installers.go:1812
(ncr.id IS NOT NULL OR (:platform = 'android' AND ncr.id IS NULL))
```

This pattern has *different semantics* — it filters per-app aggregate
status counts to only include confirmed installs. The `hostVPPInstalls`
function serves the host software list where showing all statuses
(including pending) is intentional, so no NCR filter is needed.

## Changes

- Removed the dead condition from the `last_vpp_install` UNION branch
- Added a clarifying comment explaining why no NCR filter is applied and
how this differs from other query sites
- Added changelog entry

## Testing

- No behavior change — the removed condition was always TRUE
- Existing tests pass without modification
- `go build ./server/datastore/mysql/...` compiles clean

#android #sql #cleanup

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-30 15:30:19 +01:00

1 line
327 B
Text

* Fixed a dead SQL condition in `hostVPPInstalls` that was misleading but harmless: Android VPP apps never produce `nano_command_results` entries (they use Google's Android Management API, not nanoMDM), so the previous `(hvsi.platform != 'android' OR ncr.id IS NULL)` guard was a tautology. Replaced with a clarifying comment.