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

plugin2host: Handle eval errors on the client side #235

Merged
merged 2 commits into from
Feb 25, 2023

Conversation

wata727
Copy link
Member

@wata727 wata727 commented Feb 25, 2023

For historical reasons, errors from evaluating unknown or NULL values were handled on the server side rather than on the client side.
https://github.com/terraform-linters/tflint/blob/v0.45.0/plugin/server.go#L143-L167

But given that EvaluateExpr is an endpoint that returns a cty.Value, it's preferable to handle this error on the client side.

This PR adds unknown and NULL value handling in plugin2host.GRPCClient.EvaluateExpr. Below are compatibility notes:

  • Before TFLint v0.46
    • Both server-side and client-side are checked for errors. However, the added error is never returned as the error is always returned on the server side only.
  • TFLint v0.46
    • An error is returned on the client side only.

For all host versions, conversion of errors on Protocol Buffers may not be necessary once the server side no longer returns errors, but is currently retained for compatibility reasons.

@wata727 wata727 changed the title Handle eval errors on the client side plugin2host: Handle eval errors on the client side Feb 25, 2023
// ErrUnevaluable is an error when a received expression has unevaluable references.
// Deprecated: This error is no longer returned since TFLint v0.41.
ErrUnevaluable = errors.New("")
Copy link
Member Author

@wata727 wata727 Feb 25, 2023

Choose a reason for hiding this comment

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

The error is removed in terraform-linters/tflint#1510. The ErrUnknownValue is now returned instead.

@wata727 wata727 force-pushed the handle_errors_in_client branch from 316efba to ae3978a Compare February 25, 2023 13:52
@wata727 wata727 merged commit dd804b3 into master Feb 25, 2023
@wata727 wata727 deleted the handle_errors_in_client branch February 25, 2023 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant