Skip to content

Fix repetitive diagnosis output in init response#1890

Merged
cam72cam merged 5 commits intoopentofu:mainfrom
buraksenn:1812-init-response-repetitive-diags-fix
Sep 5, 2024
Merged

Fix repetitive diagnosis output in init response#1890
cam72cam merged 5 commits intoopentofu:mainfrom
buraksenn:1812-init-response-repetitive-diags-fix

Conversation

@buraksenn
Copy link
Copy Markdown
Contributor

@buraksenn buraksenn commented Aug 5, 2024

In the issue #1812 it was explained and demonstrated clearly that init response was outputting duplicate diagnosis error. I have added Merge method to diagnostics to not add exact equal diagnostics to prevent duplicates.

Resolves #1812

Target Release

1.9.0

Checklist

  • I have read the contribution guide.
  • I have not used an AI coding assistant to create this PR.
  • I have written all code in this PR myself OR I have marked all code I have not written myself (including modified code, e.g. copied from other places and then modified) with a comment indicating where it came from.

Go checklist

  • I have run golangci-lint on my change and receive no errors relevant to my code.
  • I have run existing tests to ensure my code doesn't break anything.
  • I have added tests for all relevant use cases of my code, and those tests are passing.
  • I have only exported functions, variables and structs that should be used from other packages.
  • I have added meaningful comments to all exported functions, variables, and structs.

@buraksenn buraksenn requested a review from a team as a code owner August 5, 2024 21:56
@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 5, 2024

Reminder for the PR assignee: If this is a user-visible change, please update the changelog as part of the PR.

Signed-off-by: buraksenn <buraksenb@gmail.com>
fix typo in error string in test
Copy link
Copy Markdown
Contributor

@ollevche ollevche left a comment

Choose a reason for hiding this comment

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

Hey @buraksenn, thank you for working on this issue!

Ignoring backDiags when we print earlyConfDiags may require users to run init multiple times just to find out there are more errors that need fixing.

I would suggest trying to consolidate those diags even if they are errors. It needs to be done delicately so we don't silence any useful messages, that are not duplicated.

That will also help with failed tests, since we don't change the existing behaviour.

Happy to answer any questions and discuss potential concerns!

@buraksenn
Copy link
Copy Markdown
Contributor Author

Hey @buraksenn, thank you for working on this issue!

Ignoring backDiags when we print earlyConfDiags may require users to run init multiple times just to find out there are more errors that need fixing.

I would suggest trying to consolidate those diags even if they are errors. It needs to be done delicately so we don't silence any useful messages, that are not duplicated.

That will also help with failed tests, since we don't change the existing behaviour.

Happy to answer any questions and discuss potential concerns!

That made sense to me as well but I saw that we are not consolidation error level if source is nil so thought that this would be the fix. Then the resolution would be to expand consolidateWarnings or add another method such as consolidateErrors to prevent duplicates right @ollevche ?

@cam72cam
Copy link
Copy Markdown
Member

cam72cam commented Aug 7, 2024

Hmm, I've done some related work on one of my branches: 032c9ff#diff-cb9acfeab1fa4de42a8453d53172343075c9db7dfbd41d59569050760f455132

I can take some time today to get that PR ready for review. It could make sense to rebase this work on top of my changes once they are reviewed and merged.

@Ericwww
Copy link
Copy Markdown
Contributor

Ericwww commented Aug 7, 2024

I would also prefer the opinion that consolidate duplicated error. For some details, we could have a discussion on how to judge diagnostics is equal (or duplicated) 😄

I noticed Christian have made some progress.

@cam72cam
Copy link
Copy Markdown
Member

cam72cam commented Aug 7, 2024

Long term, we should revise how and where we are loading configuration (only once). That depends on a lot of refactoring in the command package that we have not had time to start or review.

The question is do we want to do a "generic" merge like in #1894 or do we want to have a more explicit "merge between these two sets" logic, which might make more sense here.

@ollevche
Copy link
Copy Markdown
Contributor

ollevche commented Aug 7, 2024

Sorry, I missed @cam72cam was working on a similar change! We should definitely base #1812 work on top of what Christian is doing (#1894).

I agree it makes more sense to have some explicit merge logic, that will result in a unique diag list from the previous two (backDiags and earlyConfDiags).

@cam72cam
Copy link
Copy Markdown
Member

cam72cam commented Aug 7, 2024

I agree it makes more sense to have some explicit merge logic, that will result in a unique diag list from the previous two (backDiags and earlyConfDiags).

In that case @ollevche, it probably wouldn't make sense for this PR to be based on mine, though it could be used as a reference.

@buraksenn
Copy link
Copy Markdown
Contributor Author

buraksenn commented Aug 9, 2024

I want to contribute in long-term but since this is my first commit and I'm not familiar with the project structure and architecture decisions I don't want to proceed without asking in this case. So I'm not sure which approach I should take right now. I would be glad to do the work related to consolidating etc but it would be great to clarify the approach. @cam72cam should I wait for your PR to be merged to continue?

@cam72cam
Copy link
Copy Markdown
Member

@buraksenn You should be able to continue on this branch with the approach of merging two different lists of diagnostics, removing any exact duplicates. This would probably look something like:
diags = diags.Append(earlyConfDiags.Merge(backDiags))

@buraksenn
Copy link
Copy Markdown
Contributor Author

@buraksenn You should be able to continue on this branch with the approach of merging two different lists of diagnostics, removing any exact duplicates. This would probably look something like: diags = diags.Append(earlyConfDiags.Merge(backDiags))

Thanks @cam72cam , I will continue with this. Appreciate it

…@gmail.com>

Signed-off-by: buraksenn <buraksenb@gmail.com>
@buraksenn
Copy link
Copy Markdown
Contributor Author

@ollevche can you review again if possible?

@ollevche
Copy link
Copy Markdown
Contributor

@buraksenn I'll take a look at the PR today. Thank you for working on this one!

Copy link
Copy Markdown
Contributor

@ollevche ollevche 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 the contribution!

It looks pretty good, special kudos for adding a test. However, I think we need to change the comparison logic to something similar to ConsolidateWarnings' implementation.

Left a comment with more details.

…l.com>

Signed-off-by: buraksenn <buraksenb@gmail.com>
@cam72cam cam72cam merged commit 7a02fad into opentofu:main Sep 5, 2024
@cam72cam
Copy link
Copy Markdown
Member

cam72cam commented Sep 5, 2024

Thanks @buraksenn !

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.

tofu init response repetitive diags when configuration has extra label

4 participants