Skip to content

[v3] Skip flattening if properties would clash#3801

Closed
thomas11 wants to merge 3 commits into
masterfrom
tkappler/v3-skip-flattening
Closed

[v3] Skip flattening if properties would clash#3801
thomas11 wants to merge 3 commits into
masterfrom
tkappler/v3-skip-flattening

Conversation

@thomas11

@thomas11 thomas11 commented Dec 17, 2024

Copy link
Copy Markdown
Contributor

Skip the flattening of nested properties indicated by x-ms-client-flatten if it would lead to overwriting a property, creating incorrect schema and SDKs. This case happens when inner and outer property have the same name. For a report on all occurrences see #3013.

This change is breaking and could therefore only be applied to v3 of the provider.

Resolves #3195

@github-actions

Copy link
Copy Markdown
Contributor

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

@thomas11 thomas11 changed the title Skip flattening if properties would clash [v3] Skip flattening if properties would clash Dec 18, 2024
@thomas11 thomas11 force-pushed the tkappler/v3-skip-flattening branch 2 times, most recently from f614057 to a34074d Compare December 18, 2024 10:14
@codecov

codecov Bot commented Dec 18, 2024

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 44.59459% with 41 lines in your changes missing coverage. Please review.

Project coverage is 56.87%. Comparing base (b5b0a21) to head (0bc1091).

Files with missing lines Patch % Lines
provider/pkg/gen/properties.go 44.59% 38 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3801      +/-   ##
==========================================
- Coverage   57.00%   56.87%   -0.13%     
==========================================
  Files          78       78              
  Lines       12035    12078      +43     
==========================================
+ Hits         6860     6869       +9     
- Misses       4675     4709      +34     
  Partials      500      500              

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

@mikhailshilkov mikhailshilkov left a comment

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.

Is there a way to see the effects in 3.0?

Comment thread provider/pkg/gen/properties.go Outdated
@thomas11

Copy link
Copy Markdown
Contributor Author

Is there a way to see the effects in 3.0?

There should be, by combining this change and the v3 branch and running schemagen, but at the moment that fails for unrelated reasons.

Comment thread provider/pkg/gen/properties.go
Comment thread provider/pkg/gen/properties.go Outdated
Comment thread provider/pkg/gen/properties_test.go Outdated
@t0yv0

t0yv0 commented Dec 18, 2024

Copy link
Copy Markdown

codecov actually indicates a few lines that might be interesting to check out, but I live up to you to decide what's worth it.

@danielrbradley danielrbradley left a comment

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.

I'm also struggling to parse the diff. I also wonder if a first refactor commit to pull out a function could make the actual change more clear and remove the need for the extra level of nesting.

Comment thread provider/pkg/gen/properties.go Outdated
@thomas11 thomas11 closed this Jan 8, 2025
@thomas11 thomas11 force-pushed the tkappler/v3-skip-flattening branch from d74d472 to b5b0a21 Compare January 8, 2025 08:22
@thomas11 thomas11 reopened this Jan 8, 2025
@thomas11 thomas11 force-pushed the tkappler/v3-skip-flattening branch from 656fb9b to 03eb873 Compare January 8, 2025 08:38
@thomas11 thomas11 force-pushed the tkappler/v3-skip-flattening branch from 03eb873 to 0bc1091 Compare January 8, 2025 08:52
@thomas11

thomas11 commented Jan 8, 2025

Copy link
Copy Markdown
Contributor Author

I'm also struggling to parse the diff. I also wonder if a first refactor commit to pull out a function could make the actual change more clear and remove the need for the extra level of nesting.

I don't think this is a good investment of time. The code is quite convoluted and half of it (v2) will be removed soon anyways. It's more important here that there is a single code block to remove post v3 for simple cleanup, as Mikhail also pointed out above.

@thomas11

thomas11 commented Jan 8, 2025

Copy link
Copy Markdown
Contributor Author

Superseded by #3839

@thomas11 thomas11 closed this Jan 8, 2025
thomas11 added a commit that referenced this pull request Jan 8, 2025
Skip the flattening of nested properties indicated by
[x-ms-client-flatten](https://github.com/Azure/autorest/blob/main/docs/extensions/readme.md#x-ms-client-flatten)
if it would lead to overwriting a property, creating incorrect schema
and SDKs. This case happens when inner and outer property have the same
name. For a report on all occurrences see #3013.

This change is breaking and could therefore only be applied to v3 of the
provider.

The PR is written to be reviewed commit by commit. It supersedes the
previous #3801. **I recommend hiding whitespace when reviewing since the
level of indentation of otherwise unaffected code changed.**

Resolves #3195
@thomas11 thomas11 deleted the tkappler/v3-skip-flattening branch January 29, 2025 12:11
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.

Skip flattening if properties would clash

5 participants