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: handle empty array as nil when filling record defaults #345

Merged
merged 3 commits into from
Jun 15, 2023

Conversation

aboudreault
Copy link
Contributor

@aboudreault aboudreault commented Jun 14, 2023

To avoid panic errors, in case of a wrong [] being set in the config for a record field, let's treat it as a nil and create the proper object map.

Can be reproduced with a deck sync:

_format_version: "3.0"
plugins:
- config:
    storage_config:
      redis: []
  enabled: true
  name: acme

@aboudreault aboudreault requested review from a team as code owners June 14, 2023 14:49
@codecov-commenter
Copy link

codecov-commenter commented Jun 14, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.06 🎉

Comparison is base (a49e916) 52.77% compared to head (c7b2f8e) 52.84%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #345      +/-   ##
==========================================
+ Coverage   52.77%   52.84%   +0.06%     
==========================================
  Files          69       69              
  Lines        5095     5102       +7     
==========================================
+ Hits         2689     2696       +7     
  Misses       1832     1832              
  Partials      574      574              
Flag Coverage Δ
2.1.4 17.71% <100.00%> (-18.58%) ⬇️
2.2.1.3 ?
2.2.2 17.71% <100.00%> (-18.58%) ⬇️
2.3.3 17.77% <100.00%> (-18.58%) ⬇️
2.3.3.4 ?
2.4.1 36.04% <100.00%> (-0.39%) ⬇️
2.4.1.3 47.58% <100.00%> (+0.07%) ⬆️
2.5.1.2 47.58% <100.00%> (+0.07%) ⬆️
2.5.2 ?
2.6.1 36.51% <100.00%> (+0.08%) ⬆️
2.6.1.0 ?
2.7.2 17.85% <100.00%> (-18.58%) ⬇️
2.7.2.0 ?
2.8.3 17.85% <100.00%> (-18.58%) ⬇️
2.8.4.0 49.11% <100.00%> (+0.06%) ⬆️
3.0.2 17.85% <100.00%> (-18.03%) ⬇️
3.0.2.0 49.56% <100.00%> (+0.06%) ⬆️
3.1.1 17.85% <100.00%> (-19.52%) ⬇️
3.1.1.3 51.05% <100.00%> (+0.06%) ⬆️
3.2.2 17.91% <100.00%> (-19.52%) ⬇️
3.2.2.1 ?
community 38.06% <100.00%> (+0.08%) ⬆️
enterprise 51.60% <100.00%> (+0.06%) ⬆️
enterprise-nightly ?
integration 52.84% <100.00%> (+0.06%) ⬆️
nightly 37.51% <100.00%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
kong/utils.go 88.33% <100.00%> (+0.24%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@pmalek pmalek left a comment

Choose a reason for hiding this comment

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

3 things I'd like to raise here:

  • Add a reference of koko case in the code comment so that we know which issue this is related to
  • This definitely deserves a changelog entry
  • A test case should be added. There already exists Test_fillConfigRecord so it should be as easy as adding another table driver test case there

kong/utils.go Outdated Show resolved Hide resolved
@aboudreault aboudreault force-pushed the fix/avoid-cast-error branch 2 times, most recently from 177c7d4 to aa7fca2 Compare June 14, 2023 22:34
Copy link
Member

@pmalek pmalek left a comment

Choose a reason for hiding this comment

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

Small nits, I applied those right away to speed up the delivery of this patch.

Thanks for adding changelog and tests! 🙇

kong/utils_test.go Outdated Show resolved Hide resolved
kong/utils_test.go Outdated Show resolved Hide resolved
@pmalek pmalek merged commit 7749a83 into main Jun 15, 2023
43 checks passed
@pmalek pmalek deleted the fix/avoid-cast-error branch June 15, 2023 08:41
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.

None yet

3 participants