Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug][opsgenie-plugin] Only 20 services are in scope config. Paging is not working #8259

Open
3 tasks done
antarasevich opened this issue Jan 8, 2025 · 2 comments
Open
3 tasks done
Labels
component/plugins This issue or PR relates to plugins severity/p1 This bug affects functionality or significantly affect ux type/bug This issue is a bug

Comments

@antarasevich
Copy link

Search before asking

  • I had searched in the issues and found no similar issues.

What happened

opsgenie plugin list first 20 service while scope configuring

1 Wrong parameters are passed to v1/services of opsgenie API.
correct one are offset and limit while page per_page are passed.
Example
https://api.opsgenie.com/v1/services?offset=285&limit=5

2 Only first 20 are returned back to UI (default paging of opsgenie)
No code in backend to process

What do you expect to happen

opsgenie plugin list all services available in opsgeneie for my user

How to reproduce

1 Please config more then 20 services in opsgenie
2 try to config scope

Anything else

No response

Version

v1.0.2-beta3

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@antarasevich antarasevich added the type/bug This issue is a bug label Jan 8, 2025
Copy link

dosubot bot commented Jan 8, 2025

Hello @antarasevich! I'm here to help you with any bugs, questions, or contributions you have in mind. Let's tackle this issue together!

To address the issue of the Opsgenie plugin only listing the first 20 services, you need to modify the API request parameters from page and per_page to offset and limit, as these are the correct parameters for the Opsgenie API.

Here's a general approach to fix this:

  1. Update the API Request Parameters: Change the parameters in the listOpsgenieRemoteScopes function to use offset and limit instead of page and per_page.

  2. Adjust the Pagination Logic: Implement logic to calculate the offset based on the current page and the number of services you want to retrieve per request (limit).

Here's a conceptual example of how you might adjust the code:

if page.Page == 0 {
    page.Page = 1
}
if page.PerPage == 0 {
    page.PerPage = 100
}

offset := (page.Page - 1) * page.PerPage

query := url.Values{
    "offset": []string{fmt.Sprintf("%v", offset)},
    "limit":  []string{fmt.Sprintf("%v", page.PerPage)},
}

res, err := apiClient.Get("v1/services", query, nil)
  1. Test the Changes: After making these changes, test the plugin to ensure it correctly lists all services by iterating through the pages using the offset and limit parameters.

By implementing these changes, the Opsgenie plugin should be able to list all available services for your user, rather than just the first 20.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@dosubot dosubot bot added component/plugins This issue or PR relates to plugins severity/p1 This bug affects functionality or significantly affect ux labels Jan 8, 2025
@klesh
Copy link
Contributor

klesh commented Jan 14, 2025

Thanks for reporting the issue, looking forward o your PR. 🌹

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/plugins This issue or PR relates to plugins severity/p1 This bug affects functionality or significantly affect ux type/bug This issue is a bug
Projects
None yet
Development

No branches or pull requests

2 participants