-
Notifications
You must be signed in to change notification settings - Fork 4.9k
fix(dao) check_upsert func return value on invalid options #8831
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
Conversation
The weird part is that I can only reproduce this bug via decK, I cannot reproduce it via manual API requests like using cURL, still looking for reasons, but it seems that this bug is not related to decK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@windmgc This seems to affect only the
|
@ms2008 Yes you're right, after reading decK and Kong admin API's code, I confirm that this bug will affect Before the fix:
After the fix:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the proper fix. You are changing the default return pattern for errors, which is nil, error-string
, with an addition error table in the cases for the DAO. In this case it works by chance, but you have to check what function is calling check_upsert()
to understand why it behaves as you expect when returning nil, nil
.
Hi @locao, I don't think I'm changing the default return pattern of three values for the DAO functions, because Line 819 in 830bbe8
DAO:upsert Line 1192 in 830bbe8
So actually I don't quite get your point, could you explain more about it? Thanks! |
Summary
Hi, this PR aims to fix the bug that will cause an unexpected 404 error on creating/updating configs with invalid options.
A simple way to reproduce:
validate_options_value
funcAs it is shown in the error log, the message is very confusing.
The reason for this weird behaviour is that the
check_upsert
function is returning a wrong list of values, it should be 4 values(starting with 2 nils), but now it returns 3 valueskong/kong/db/dao/init.lua
Line 571 in fcb7275
And then it makes
err_t
a nil valuekong/kong/db/dao/init.lua
Lines 1201 to 1207 in fcb7275
Which leads to the wrong 404 logic(because err_t is nil)
kong/kong/api/endpoints.lua
Lines 488 to 495 in fcb7275
After the fix, the error becomes meaningful
Full changelog
Issue reference
Fix FTI-4021