trino-python-client icon indicating copy to clipboard operation
trino-python-client copied to clipboard

Checking for config headers to be both present and non-empty

Open derek-pyne opened this issue 1 year ago • 2 comments

Addresses #262 .

Handles cases where these config headers are present in the request, but with an empty string as their value. Currently, an error is raised when trying to parse the empty strings. This PR addresses this by checking that these headers are not only present, but not empty.

These headers being present with empty values is not normally expected, although we'd like to protect against it for cases like a proxy sitting in between Trino and the client that is altering the headers (which is the case for me).

Notes:

  • Added checks for all headers in process that might hit this issue because the values are parsed. HEADER_SET_SESSION, HEADER_SET_ROLE and HEADER_ADDED_PREPARE are currently failing to parse if the header value is empty
  • The test reproduces the error, but I don't fully understand the mocking that is happening. Looking for guidance if there is a different preferred way of testing this

Non-technical explanation

Protecting against headers being present but without data

Release notes

( ) This is not user-visible or docs only and no release notes are required. ( ) Release notes are required, please propose a release note for me. (x) Release notes are required, with the following suggested text:

* Fix value error with present but empty headers. ([#262](https://github.com/trinodb/trino-python-client/issues/262))

derek-pyne avatar Oct 13 '22 12:10 derek-pyne

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

cla-bot[bot] avatar Oct 13 '22 12:10 cla-bot[bot]

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

cla-bot[bot] avatar Oct 13 '22 14:10 cla-bot[bot]

Morning! Just checking in if this is a change we'd like to include, or something we want to discuss more :)

derek-pyne avatar Oct 27 '22 13:10 derek-pyne

@derek-pyne I've been travelling so did not get a chance to re-review/merge. I'll get to this starting the weekend/Monday.

Sorry about the long wait.

hashhar avatar Oct 27 '22 14:10 hashhar

@cla-bot check

hashhar avatar Oct 27 '22 14:10 hashhar

The cla-bot has been summoned, and re-checked this pull request!

cla-bot[bot] avatar Oct 27 '22 14:10 cla-bot[bot]

@derek-pyne I've been travelling so did not get a chance to re-review/merge. I'll get to this starting the weekend/Monday.

Sorry about the long wait.

All good! No rush, just checking in

derek-pyne avatar Oct 27 '22 15:10 derek-pyne

Squashed the commits. Will merge once CI is done. Thanks for the fix.

hashhar avatar Oct 31 '22 09:10 hashhar