Skip to content

Commit

Permalink
Fix a panic when downloading a software installer that exists in the …
Browse files Browse the repository at this point in the history
…DB but not in the storage (#19527)
  • Loading branch information
mna authored and georgekarrv committed Jun 20, 2024
1 parent 2234970 commit 63e4c5f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions changes/19324-fix-panic-in-download-software
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Fixed a panic (API returning code 500) when the software installer exists in the database but the installer does not exist in the storage.
2 changes: 1 addition & 1 deletion ee/server/service/software_installers.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (svc *Service) getSoftwareInstallerBinary(ctx context.Context, storageID st
return nil, ctxerr.Wrap(ctx, err, "checking if installer exists")
}
if !exists {
return nil, ctxerr.Wrap(ctx, err, "does not exist in software installer store")
return nil, ctxerr.Wrap(ctx, notFoundError{}, "does not exist in software installer store")
}

// get the installer from the store
Expand Down
3 changes: 3 additions & 0 deletions server/service/integration_enterprise_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9420,6 +9420,9 @@ func (s *integrationEnterpriseTestSuite) TestSoftwareInstallerUploadDownloadAndD

// check activity
s.lastActivityOfTypeMatches(fleet.ActivityTypeDeletedSoftware{}.ActivityName(), fmt.Sprintf(`{"software_title": "ruby", "software_package": "ruby.deb", "team_name": "%s", "team_id": %d, "self_service": true}`, createTeamResp.Team.Name, createTeamResp.Team.ID), 0)

// download the installer, not found anymore
s.Do("GET", fmt.Sprintf("/api/latest/fleet/software/%d/package?alt=media", titleID), nil, http.StatusNotFound, "team_id", fmt.Sprintf("%d", *payload.TeamID))
})
}

Expand Down

0 comments on commit 63e4c5f

Please sign in to comment.