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

Don't print UnexpectedStateError.LastError when it's nil #1359

Open
kayrus opened this issue Jul 5, 2024 · 0 comments
Open

Don't print UnexpectedStateError.LastError when it's nil #1359

kayrus opened this issue Jul 5, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@kayrus
Copy link

kayrus commented Jul 5, 2024

SDK version

...
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0

Use-cases

In case when the retry func faces an unexpected resource status it returns unexpected state 'ACTIVE', wanted target 'DELETED'. last error: %!s(<nil>).

Attempted Solutions

Proposal

There should be more cleaner error report, when LastError is nil: unexpected state 'ACTIVE', wanted target 'DELETED', e.g.

func (e *UnexpectedStateError) Error() string {
        if e.LastError == nil {
                return fmt.Sprintf( 
                        "unexpected state '%s', wanted target '%s'.",
                        e.State,
                        strings.Join(e.ExpectedState, ", "),
                )
        }
        return fmt.Sprintf(
                "unexpected state '%s', wanted target '%s'. last error: %s",
                e.State,
                strings.Join(e.ExpectedState, ", "),
                e.LastError,
        )
}

References

"unexpected state '%s', wanted target '%s'. last error: %s",

https://github.com/search?q=%22last+error%3A+%25%21s%28%3Cnil%3E%29%22&type=issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant