Skip to content

fix: file conversion from 2.8 to 3.4 for post-function plugin#1974

Merged
harshadixit12 merged 8 commits into
mainfrom
fix/conversion-2.8-3.4
Apr 14, 2026
Merged

fix: file conversion from 2.8 to 3.4 for post-function plugin#1974
harshadixit12 merged 8 commits into
mainfrom
fix/conversion-2.8-3.4

Conversation

@harshadixit12
Copy link
Copy Markdown
Contributor

@harshadixit12 harshadixit12 commented Apr 6, 2026

Summary

Referring to https://developer.konghq.com/gateway/upgrade/lts-upgrade-28-34/, if the 2.8 config has both functions (deprecated) and access keys in the plugin config, we will modify logic to replace the legacy key with new key.

New approach:

  • Both exist, old field is empty: Choose new
  • Both exist, both have values:: Error
  • Both exist, new field is empty: Choose old
  • Only old exists: Choose old

How 2.8 used to work with functions and access

Based on https://legacy-gateway-2-8--kongdocs.netlify.app/hub/kong-inc/post-function/how-to/phases/ - the fields functions and access refer to the different phases in which we can configure the plugin to execute.
In kong 3.0, functions was removed, and access phase was to be used instead.

Even in 2.8 - functions and access are treated as mutually exclusive - sync fails if both are present in config and are non-empty.

Fixes #1933

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 6, 2026

Codecov Report

❌ Patch coverage is 27.47253% with 66 lines in your changes missing coverage. Please review.
✅ Project coverage is 32.72%. Comparing base (1e62866) to head (f743756).
⚠️ Report is 17 commits behind head on main.

Files with missing lines Patch % Lines
convert/plugin_updates.go 9.09% 39 Missing and 1 partial ⚠️
convert/plugin_updates_310.go 34.48% 11 Missing and 8 partials ⚠️
convert/convert.go 30.00% 5 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1974      +/-   ##
==========================================
- Coverage   32.88%   32.72%   -0.16%     
==========================================
  Files          77       77              
  Lines        6988     7046      +58     
==========================================
+ Hits         2298     2306       +8     
- Misses       4506     4545      +39     
- Partials      184      195      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@harshadixit12 harshadixit12 force-pushed the fix/conversion-2.8-3.4 branch 2 times, most recently from 1b817b1 to beb9839 Compare April 10, 2026 11:54
@harshadixit12 harshadixit12 marked this pull request as ready for review April 13, 2026 04:52
- /r1
plugins:
- config:
# Both legacy and new fields are non empty
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This config should have resulted in an error, right?
We have set errorExpected: false and the tests pass.

Copy link
Copy Markdown
Contributor Author

@harshadixit12 harshadixit12 Apr 13, 2026

Choose a reason for hiding this comment

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

Yes - I wanted to check with you about this - during conversion of plugin config as of now in other functions, the errors are printed to console, but execution is not halted - https://github.com/Kong/deck/blob/main/convert/plugin_updates.go#L243
Shall I modify the function signature and return error instead?

This is what the output looks like

> go run main.go file convert --from 2.8 --to 3.4 --input-file x.yaml -o y.yaml

From the 'x.yaml' config file,
the _format_version field has been migrated from '1.1' to '3.0'.

Error: both legacy configuration field "functions" and new field "access" have values in plugin post-function, please remove the legacy field
Automatically converted legacy configuration field "functions" to the new field "access" in plugin post-function

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should halt the conversion and show the error. Otherwise, the error output would get mixed with other information printed. It would be hard to spot the error as the file size increases and there's too much info on the screen and a non-zero exit code won't give any feedback to our users to check for the printed warnings..

Shall I modify the function signature and return error instead?

Yes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, will update.

@harshadixit12 harshadixit12 force-pushed the fix/conversion-2.8-3.4 branch from 75311be to f743756 Compare April 14, 2026 06:17
@harshadixit12 harshadixit12 merged commit 6b96392 into main Apr 14, 2026
44 checks passed
@harshadixit12 harshadixit12 deleted the fix/conversion-2.8-3.4 branch April 14, 2026 06:34
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.

2.8 -> 3.4 conversion is overwriting function definitions from "access" fields during conversions.

3 participants