Skip to content

Conversation

SarahFrench
Copy link
Member

@SarahFrench SarahFrench commented Sep 19, 2025

This PR moves some fixes to the radek/pss-read-write branch out of #37323

I tested the process of initialising a working directory end to end using the pss provider and our changes to the terraform-plugin-go repo, and in the process made these changes to the Core-side of ReadStateBytes.

The main changes in this PR are:

  • Being clear that the io.EOF sentinel error is not expected to be accompanied with any chunk information, i.e. no bytes and no diagnostics.
  • Adding a call to CloseSend to close the stream, if reading the state didn't encounter any grpc errors or custom error diagnostics from the provider.

Target Release

N/A

Rollback Plan

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

CHANGELOG entry

  • This change is user-facing and I added a changelog entry.
  • This change is not user-facing.

@SarahFrench SarahFrench changed the title Sarah/pss read write updates Sarah's updates to radek/pss-read-write Sep 19, 2025
Comment on lines 1517 to 1521
if err == io.EOF {
// End of stream, we're done
if chunk != nil {
// TODO: The EOF error could be just returned alongside the last chunk?
resp.Diagnostics = resp.Diagnostics.Append(convert.ProtoToDiagnostics(chunk.Diagnostics))
}
// No chunk is returned alongside an EOF.
// And as EOF is a sentinel error it isn't wrapped as a diagnostic.
break
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Please see this comment in our terraform-plugin-go PR explaining why we will never see a chunk alongside the EOF error here: https://github.com/hashicorp/terraform-plugin-go/pull/563/files#r2362735975

@SarahFrench SarahFrench marked this pull request as ready for review September 19, 2025 12:32
@SarahFrench SarahFrench requested a review from a team as a code owner September 19, 2025 12:32
Copy link
Member

@radeksimko radeksimko 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 all the work and the tests! 👍🏻

@SarahFrench SarahFrench merged commit a578ac2 into radek/pss-read-write Sep 19, 2025
15 checks passed
@SarahFrench SarahFrench deleted the sarah/pss-read-write-updates branch September 19, 2025 13:29
radeksimko pushed a commit that referenced this pull request Sep 19, 2025
* Update code to not expect a chunk when EOF encountered

* Return early if any grpc errors are encountered during ReadStateBytes

* Close the stream with CloseSend once everything's read without error. Add test case about handling grpc errors from CloseSend.

* Fix test case about warnings: We would expect to receive a chunk with data alongside the warning and have a normal closing of the stream after EOF

* Add log line, remove unneeded type info
radeksimko pushed a commit that referenced this pull request Sep 23, 2025
* Update code to not expect a chunk when EOF encountered

* Return early if any grpc errors are encountered during ReadStateBytes

* Close the stream with CloseSend once everything's read without error. Add test case about handling grpc errors from CloseSend.

* Fix test case about warnings: We would expect to receive a chunk with data alongside the warning and have a normal closing of the stream after EOF

* Add log line, remove unneeded type info
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants