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

feat: endpoint reachability plugin #720

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

5war00p
Copy link

@5war00p 5war00p commented Oct 31, 2024

Endpoint Reachability Plugin

  • Brief Description of Changes
    Added new plugin that checks and validates whether an endpoint (url) is reachable or unreachable.

Motivation: (optional)

  • Why this change is necessary or beneficial
    Its a preventive check to not do unnecessary actions without a proper input

Related Issues: (optional)

@roh26it
Copy link
Collaborator

roh26it commented Nov 8, 2024

Thanks for the PR @5war00p!

Does this only check the entire content of the request to assume that it contains a URL?

We also have another plugin - https://github.com/Portkey-AI/gateway/blob/main/plugins/default/validUrls.ts

Is that conflicting?

@5war00p
Copy link
Author

5war00p commented Nov 8, 2024

This just does almost same, but instead of GET request I'm using HEAD request also we as we need to validate endpoint is reaching or not just header is fine no need validate dns separately.

Copy link
Contributor

@narengogi narengogi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just that this assumes that the response only contains a URL. in comparison,
https://github.com/Portkey-AI/gateway/blob/main/plugins/default/validUrls.ts feels more complete, I think it's a good idea to make a HEAD request to check the validity of a URL, you can perhaps add it as a fallback in the code of the existing plugin. That would be a 2 line change and more robust

@5war00p
Copy link
Author

5war00p commented Nov 11, 2024

To your point, validUrl ideally should be a regexp check thats what name speaks about. Where as endpointReachability make sure it reaches. If we really don't need 2 separate then we can merge, but validUrl can be used to validate a url input but if we make sure its a reachable one then merging both will be good idea.

let data = null;

try {
let text = getText(context, eventType);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestion here is use regex to get all the URLs available from text and validate them using URL or some other way.

With this we can have config weather to run plugin for all the endpoints or first endpoint found within the text.

What do you think? @5war00p

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense if text might contain >1 url, however this issue is to build a plugin for endpoint reachability right? and we should use this util func in another which extracts urls and check each url using this plugin. Correct me if I went off.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your thought makes sense, but this PR is a plugin PR which I think doesn't make sense to use it as utility function. I think we should focus on keep this as individual plugin. keeping that I prefer we should go for regex match.

As an enhancement I think we shouldn't just blindly hit the URL, we should ask user which type of method they're thinking of ex: GET and POST and let plugin do OPTIONS request and make sure the endpoint(s) support the user requested methods.

let me know if this makes sense to you.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if thats the case we should make it as a new separate plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants