Skip to content

Commit e65f291

Browse files
Fix: Asset dropdown limit not being respected (#43)
1 parent 4a8ee95 commit e65f291

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

pkg/plugin/resources.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,20 @@ func (d *SiftDatasource) callResourceAssets(ctx context.Context, req *backend.Ca
2626
return err
2727
}
2828

29-
params := v // copy query params then overwrite any defaults
29+
params := v
30+
limit := ResourceLimit
3031
if params.Get("limit") != "" {
31-
params.Set("paginationSearchParams.limit", params.Get("limit"))
32-
} else {
33-
params.Set("paginationSearchParams.limit", strconv.Itoa(ResourceLimit))
32+
if parsedLimit, err := strconv.Atoi(params.Get("limit")); err == nil && parsedLimit > 0 {
33+
limit = parsedLimit
34+
}
3435
}
3536

3637
assets, err := handlePaginatedRequest[Asset](d, apiRequest{
3738
pCtx: req.PluginContext,
3839
method: "GET",
3940
path: "/api/v1/assets",
4041
queryParams: params,
41-
}, ResourceLimit, 1, func(respBody []byte) ([]Asset, string, error) {
42+
}, limit, 1, func(respBody []byte) ([]Asset, string, error) {
4243
response := listAssetsQueryResponse{}
4344
err := json.Unmarshal(respBody, &response)
4445
if err != nil {

0 commit comments

Comments
 (0)