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: fill defaults for non-required field of type "record" #336

Merged
merged 7 commits into from
Jun 6, 2023

Conversation

nishant95
Copy link
Contributor

@nishant95 nishant95 commented Jun 5, 2023

Fixes #334

Adds a check for required while recusrively filling defaults for subconfig of type record.
Current behaviour of KIC is out of sync from Kong Lua implementation.

There are some field "required" checks in Lua code: here and here
These checks are missing form go code

@nishant95 nishant95 requested a review from a team as a code owner June 5, 2023 09:21
@aboudreault
Copy link
Contributor

aboudreault commented Jun 5, 2023

thanks @nishant95! I just tested your branch and I still have the same issue, my field is set to null. My fix in #333 works but I understand that our PRs don't fix exactly the same thing. To support default with set of record, we'll need to merge both, right?

@nishant95
Copy link
Contributor Author

@aboudreault Yes, I raised this PR for issue #334 , this deals with record type only.
Your PR looks good and should fix it for type "set".

But shouldn't there be a similar handling for type "map" as well? Similar to this in Lua.

@aboudreault
Copy link
Contributor

@nishant95 this is possible yeah. Let's try to release this fix and #333, I will create a ticket for the map type.

@rainest
Copy link
Collaborator

rainest commented Jun 6, 2023

Overriding linter failure and merging cause it ain't worth waiting to round trip to the upstream branch and the error is inscrutable:

Check failure on line 2262 in kong/utils_test.go
GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/kong) (gci)

golangci, please just print the actual command you need to run. Furthermore, the import block didn't change between those commits; it shouldn't start failing. This is not an import >:(

10:47:38-0700 esenin $ gci diff --skip-generated  -s standard -s default -s "prefix(github.com/kong)" utils_test.go 
--- utils_test.go
+++ utils_test.go
@@ -2259,4 +2259,4 @@
 			}
 		})
 	}
-}
\ No newline at end of file
+}

Going to fix in the release changelog commit.

@rainest rainest merged commit 534c363 into Kong:main Jun 6, 2023
33 of 34 checks passed
@rainest rainest mentioned this pull request Jun 6, 2023
@@ -1671,3 +2079,184 @@ func Test_FillPluginsDefaults_SetType(t *testing.T) {
})
}
}

func Test_FillPluginsDefaults_Acme(t *testing.T) {
RunWhenKong(t, "==3.3.0")
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason we want to run this against 3.3 only? If so then I believe this line deserves a comment why that's the case. It's not obvious to the reader why this particular version was chosen here and deserves a special treatment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pmalek You are right, this check is not needed. This is a residual check which I added initially as the schema for this plugin changed a lot over different kong versions, this is of no use now as the schema has been added to the test itself.

Copy link
Member

Choose a reason for hiding this comment

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

Great! This should fix it then right? #342

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this should fix it: #343 Else the test would fail for many of the kong versions as the schema for Acme plugin would be different.

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.

wrong default filled for non-required field of type "record"
5 participants