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

fix(admin) return HTTP 404 on PUT with non-existing PK #3007

Merged
merged 1 commit into from
Nov 3, 2017

Conversation

thibaultcha
Copy link
Member

Background

Due to unfortunate legacy design decisions, our HTTP PUT handlers behave
in the following way as of today:

  1. if the payload does not have the entity's primary key values,
    we attempt an insert()
  2. if the payload has primary key values, we attempt an update()

Issue

While acknowledging this isn't the appropriate/desired behavior for a
PUT handler, #2774 has raised the following concern:

When a PUT payload contains an non-existing primary key (attempt to
create an entity), the endpoint responds HTTP 200 OK, but the entity is
not created, and the response body is empty.

Root cause & resolution

This was due to a mis-usage of the dao:update() API.

While this change will not allow #2774 to work the way it is
expected of it to work, this will help alleviate confusion by at least
returning the appropriate HTTP status code, at least in the way our
Admin API implements PUT handlers...

Appendix

In the future, and as we are working towards a new model comprised of a
new Admin API, we promise ourselves to implement a more appropriate
behavior for PUT endpoints.

Fix #2774

Background
----------

Due to unfortunate legacy design decisions, our HTTP PUT handlers behave
in the following way as of today:

1. if the payload does not have the entity's primary key values,
   we attempt an insert()
2. if the payload has primary key values, we attempt an update()

Issue
-----

While acknowledging this isn't the appropriate/desired behavior for a
PUT handler, #2774 has raised the following concern:

> When a PUT payload contains an non-existing primary key (attempt to
create an entity), the endpoint responds HTTP 200 OK, but the entity is
not created, and the response body is empty.

Root cause & resolution
-----------------------

This was due to a mis-usage of the `dao:update()` API.

While this change will **not** allow #2774 to work the way it is
expected of it to work, this will help alleviate confusion by at least
returning the appropriate HTTP status code, at least in the way our
Admin API implements PUT handlers...

Appendix
--------

In the future, and as we are working towards a new model comprised of a
new Admin API, we promise ourselves to implement a more appropriate
behavior for PUT endpoints.

Fix #2774
@p0pr0ck5
Copy link
Contributor

p0pr0ck5 commented Nov 3, 2017

Seems sane; do we have a doc update to go with it?

@thibaultcha
Copy link
Member Author

do we have a doc update to go with it?

On my TODO list! 😉

@kikito kikito merged commit fd36677 into master Nov 3, 2017
@kikito kikito deleted the fix/admin-404-on-put branch November 3, 2017 14:46
thibaultcha added a commit to Kong/docs.konghq.com that referenced this pull request Nov 8, 2017
As a follow-up to:

Kong/kong#3007 (PR)
Kong/kong#2774 (issue)

This commit adds clarifications as to the current behavior of PUT
endpoints on the Admin API. As much as we acknowledge that their
behavior is not compliant with the HTTP specifications, we do wish to
clarify their behavior to avoid confusion as of today, until a different
implementation sees the light of day.
@thibaultcha
Copy link
Member Author

@p0pr0ck5 Have a look at Kong/docs.konghq.com#548 for docs updates clarifying this behavior! :)

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.

3 participants