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: Escape paths containing the keyword "item" #4900

Merged
merged 13 commits into from
Sep 13, 2024

Conversation

CasperWSchmidt
Copy link
Contributor

Fixes #4814

@CasperWSchmidt
Copy link
Contributor Author

@microsoft-github-policy-service agree

@baywet
Copy link
Member

baywet commented Jun 28, 2024

@CasperWSchmidt thanks for starting this. Can you add a unit test in the kiota builder tests please? This way we can iterate on the solution with confidence.

@CasperWSchmidt
Copy link
Contributor Author

@baywet I'm not sure what unit test to add. I can include a test using the exact structure I'm struggling with, but that seems to be a bit too large for at unit test?

@andrueastman
Copy link
Member

@CasperWSchmidt Maybe you can take a look at a test like this one?
You can essentially use a subset of your description as the input and assert that the class and namespace exist with the expected names in the codeDom.

public async Task HandlesSpecialCharactersInPathSegment()

@CasperWSchmidt
Copy link
Contributor Author

Hi @andrueastman and @baywet
I'm sorry for the late reply. I've tried adding a unit test that verifies what I expect. I've commented out the Assert that fails with the current implementation. I also believe I'm catching the issue with the original implementation (without the escaping I've done). Please let me know if you need me to do something else/more.

@baywet
Copy link
Member

baywet commented Aug 13, 2024

@CasperWSchmidt Thanks for your continuous efforts here.
I found some time to look at your PR and make further progress.
This still needs to be refactored to avoid duplication for constants and conditions. Can you take it from here please?

@CasperWSchmidt
Copy link
Contributor Author

@baywet Thank you for helping out! I don't know what constants and conditions must be refactored to avoid duplication.

@CasperWSchmidt
Copy link
Contributor Author

@baywet Thank you for helping out! I don't know what constants and conditions must be refactored to avoid duplication.

Ah, the "Item" and "Item_escaped" constants? What's the best place to put them?

@CasperWSchmidt CasperWSchmidt marked this pull request as ready for review August 23, 2024 12:09
@CasperWSchmidt CasperWSchmidt requested a review from a team as a code owner August 23, 2024 12:09
@CasperWSchmidt
Copy link
Contributor Author

I tried playing around with changing Item_escaped with something else and noticed that my latest changes doesn't include the constants in OpenApiUrlTreeNodeExtensions. When looking into it, I noticed another private const string EscapeSuffix = "Escaped"; I wonder if I could (and should) consolidate this with the other changes to have a single escape suffix across the builder?

@baywet
Copy link
Member

baywet commented Aug 26, 2024

I wonder if I could (and should) consolidate this with the other changes to have a single escape suffix across the builder?

Yes, and please place the constants in the Extensions class.

@CasperWSchmidt
Copy link
Contributor Author

@baywet Thanks, I finally got around to fixing it. I guess it's ready for review/merge.

Copy link
Member

@baywet baywet left a comment

Choose a reason for hiding this comment

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

Thank you for making the changes!

Can you also add a changelog entry please? (unreleased, changed)

Copy link
Member

@baywet baywet left a comment

Choose a reason for hiding this comment

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

Made the changelog entry myself

@baywet baywet enabled auto-merge (squash) September 13, 2024 12:10
@baywet baywet merged commit 7f0cb96 into microsoft:main Sep 13, 2024
208 checks passed
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.

Generated builder hickup
3 participants