Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/fix-whatsapp-version-check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fixed maintained apps ingestion failing due to WhatsApp version scheme change.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package externalrefs

import (
"fmt"
"strings"

maintained_apps "github.com/fleetdm/fleet/v4/ee/maintained-apps"
Expand All @@ -10,10 +9,11 @@ import (
func WhatsAppVersionShortener(app *maintained_apps.FMAManifestApp) (*maintained_apps.FMAManifestApp, error) {
homebrewVersion := app.Version

// Legacy WhatsApp versions used a "2." prefix added by Homebrew that
// needed to be stripped (e.g. "2.25.16.81" -> "25.16.81").
// Newer versions (e.g. "26.26.12") no longer carry this prefix.
if strings.HasPrefix(homebrewVersion, "2.") {
app.Version = strings.TrimPrefix(homebrewVersion, "2.")
} else {
return app, fmt.Errorf("Expected WhatsApp version to start with '2.' but found '%s'", homebrewVersion)
}

return app, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

maintained_apps "github.com/fleetdm/fleet/v4/ee/maintained-apps"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestWhatsAppVersionShortener(t *testing.T) {
Expand All @@ -14,17 +15,17 @@ func TestWhatsAppVersionShortener(t *testing.T) {
Version: "2.25.16.81",
}
result, err := WhatsAppVersionShortener(app)
assert.NoError(t, err)
require.NoError(t, err)
assert.Equal(t, "25.16.81", result.Version)
})

t.Run("unexpected version format", func(t *testing.T) {
t.Run("new version scheme without 2. prefix", func(t *testing.T) {
app := &maintained_apps.FMAManifestApp{
UniqueIdentifier: "whatsapp/darwin",
Version: "3.25.16.81",
Version: "26.26.12",
}
result, err := WhatsAppVersionShortener(app)
assert.Error(t, err)
assert.Equal(t, "3.25.16.81", result.Version)
require.NoError(t, err)
assert.Equal(t, "26.26.12", result.Version)
})
}
Loading