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

HTTP Client POST not working as intended #52

Open
echlebek opened this issue Jun 1, 2021 · 1 comment
Open

HTTP Client POST not working as intended #52

echlebek opened this issue Jun 1, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@echlebek
Copy link
Contributor

echlebek commented Jun 1, 2021

Recently, a community user attempted to use the HTTP client, but was unable to, because the client sends POST requests to the incorrect URL.

The issue is that the library uses a URL generated in part by URIPath, which includes the namespace and name of the resource. However, when targeting routes with POST, this results in incorrect paths.

The library should handle these situations gracefully and come up with the correct URL when instructed to use POST.

@echlebek echlebek added the bug Something isn't working label Jun 1, 2021
@SegFaultAX
Copy link

SegFaultAX commented Jun 1, 2021

I was the reporter of this bug in Slack.

The above issue doesn't fully summarize the problem. URIPath is valid when posting to a resource that already exists. The problem is when using client.PostResource to create a resource, URIPath is going to generate a non-existent resource path that cannot be used for creates. As a concrete example, consider using PostResource to generate a new check config. The URL that needs to be POST'd to is something like /api/core/v2/namespaces/<ns>/checks but because PostResource is relying on newRequest which in turn calls on the underlying CheckConfig's URIPath, it's going to get a url like /api/core/v2/namespaces/<ns>/checks/<check-name> which is incorrect.

I wonder if it would be better to expand the API for the client to have resource-specific CRUD operations rather than generic *Resource actions. At the cost of making the API for the client significantly larger in terms of number of methods, it would allow us to provide a more user-friendly API that handles all the low level resource machinery for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants