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

existing Data Sources now return errors on 404s #8858

Conversation

NickElliot
Copy link
Contributor

@NickElliot NickElliot commented Sep 5, 2023

Fixes hashicorp/terraform-provider-google#12873

This does not guarantee all data sources will return errors if empty -- there are some for which this is intended functionality such as data sources filtering for what data they would have displayed, or if an endpoint is successfully reached due to actually existing but simply containing no information for the data source to display, as their lack of data is intentional.

Local testing entailed doing trial runs of data sources that had more unusual configurations (e.g. 1), and verifying functionality for a few different resources that the more universal configurations (e.g. 1 and 2) that involved either replacing references to transport_tpg.HandleNotFoundError with transport_tpg.HandleDataSourceNotFoundError or wrapping standard resource read functions with a check for an empty ID, as this would be returned by these resource reads using transport_tpg.HandleNotFoundError.

Should not result in false-positives as the two main functionality changes due the following:

If using the transport_tpg.HandleDataSourceNotFoundError return an error on 404 directly, maintains logic for returning non 404 errors

If using the d.Id == "" check, the d.SetId("") would be passed up via the transport_tpg.HandleNotFoundError function, in which case this is the Error we directly are intending to add (the example functionality previously added via Container Cluster per parent issue)

Release Note Template for Downstream PRs (will be copied)


@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 75 files changed, 519 insertions(+), 113 deletions(-))
Terraform Beta: Diff ( 86 files changed, 618 insertions(+), 124 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3002
Passed tests 2700
Skipped tests: 301
Affected tests: 1

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccSpannerDatabaseIamPolicy

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccSpannerDatabaseIamPolicy[Debug log]

Rerun these tests in REPLAYING mode to catch issues

$\textcolor{green}{\textsf{No issues found for passed tests after REPLAYING rerun.}}$


$\textcolor{green}{\textsf{All tests passed!}}$
View the build log or the debug log for each test

@NickElliot NickElliot marked this pull request as ready for review September 6, 2023 19:26
@@ -84,7 +84,7 @@ func dataSourceGoogleCloudIdentityGroupsRead(d *schema.ResourceData, meta interf
return nil
})
if err != nil {
return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("CloudIdentityGroups %q", d.Id()))
return transport_tpg.HandleDataSourceNotFoundError(err, d, fmt.Sprintf("CloudIdentityGroups %q", d.Id()), "")
Copy link
Member

Choose a reason for hiding this comment

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

We don't have a usable ID or URL to send as the last parameter here, but what do you think about at least "Groups" or something?

Copy link
Contributor Author

@NickElliot NickElliot Sep 7, 2023

Choose a reason for hiding this comment

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

The reason nothing is passed is this error is never actually a 404 -- it returns a different web error, which means the argument is unused downstream. That said, since I updated it to use the new function (was primarily meant to ensure the lack of breaking change should it need updating in the future), I'll update it to use "Groups" in case the 404 is hit in the future due to updates on Cloud Identity's end

Copy link
Member

Choose a reason for hiding this comment

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

That makes sense, thanks for the explanation!

Copy link
Member

@c2thorn c2thorn left a comment

Choose a reason for hiding this comment

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

Shouldn't there be a changelog note for this?

@NickElliot
Copy link
Contributor Author

Yes, I started writing one for this and the Default Values but got waylayed by the larger DCL release, I'll hold off the merge until thats ready

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 75 files changed, 519 insertions(+), 113 deletions(-))
Terraform Beta: Diff ( 86 files changed, 618 insertions(+), 124 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3008
Passed tests 2706
Skipped tests: 302
Affected tests: 0

$\textcolor{green}{\textsf{All tests passed in REPLAYING mode.}}$
View the build log

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.

3 participants