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(sdk/go): ensure empty string cannot be passed as path parameters #3722

Merged
merged 7 commits into from
Dec 16, 2024

Conversation

GeorgeMac
Copy link
Member

@GeorgeMac GeorgeMac commented Dec 13, 2024

Supports #3716

@erka spotted that empty string can be passed to GetNamespaces which leads to the HTTP client making a list namespaces operation when the key is empty. This is due to the fact we strip slash on our paths.

This updates the SDK generator to support a new protobuf method option flipt.options.flipt_client.
This option includes the ability to define path defaults (strings only currently).
When a default is found in the HTTP client generation, it is set to the default if the path parameter is the zero value ("").

@GeorgeMac GeorgeMac requested a review from a team as a code owner December 13, 2024 16:15
@GeorgeMac
Copy link
Member Author

I expect this will fail. We may need to merge after @erka original PR / update more code paths.
We will see when CI finishes.

Copy link

codecov bot commented Dec 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.55%. Comparing base (42a99c6) to head (6962272).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3722      +/-   ##
==========================================
+ Coverage   64.51%   64.55%   +0.03%     
==========================================
  Files         170      170              
  Lines       17163    17163              
==========================================
+ Hits        11073    11079       +6     
+ Misses       5397     5393       -4     
+ Partials      693      691       -2     
Flag Coverage Δ
unittests 64.55% <ø> (+0.03%) ⬆️

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

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

@GeorgeMac
Copy link
Member Author

Bare with me while I fix these tests

@GeorgeMac
Copy link
Member Author

I just pushed an update to this which takes a different approach.
I will adjust the description to match.

TL;DR exploring setting path defaults as protobuf options.

@GeorgeMac GeorgeMac force-pushed the gm/sdk-http-validate-empty branch from f612fa1 to a5d2748 Compare December 16, 2024 12:04
@GeorgeMac GeorgeMac requested review from markphelps and erka December 16, 2024 12:06
Comment on lines +89 to +91
if v.Key == "" {
v.Key = "default"
}
Copy link
Member Author

Choose a reason for hiding this comment

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

See here for example output for new option.

Copy link
Collaborator

@markphelps markphelps left a comment

Choose a reason for hiding this comment

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

Nice

@GeorgeMac GeorgeMac added the automerge Used by Kodiak bot to automerge PRs label Dec 16, 2024
@kodiakhq kodiakhq bot merged commit 6a60837 into main Dec 16, 2024
40 checks passed
@kodiakhq kodiakhq bot deleted the gm/sdk-http-validate-empty branch December 16, 2024 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Used by Kodiak bot to automerge PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants