Skip to content

GH-35288: [Python][FlightRPC] Accept str header keys and values in FlightCallOptions - #55944

Open
AynSiddiqui wants to merge 1 commit into
apache:mainfrom
AynSiddiqui:GH-35288-flight-str-headers
Open

AynSiddiqui wants to merge 1 commit into
apache:mainfrom
AynSiddiqui:GH-35288-flight-str-headers

Conversation

@AynSiddiqui

@AynSiddiqui AynSiddiqui commented Dec 3, 2026 •

Copy link
Copy Markdown

Rationale for this change

Passing str headers to FlightCallOptions(headers=...) raises TypeError: expected bytes, str found. ServerCallContext.add_header and ServerCallContext.add_trailer already accept str by converting it to bytes.

What changes are included in this PR?

FlightCallOptions.__init__ uses tobytes on each header key and value. It encodes str as UTF-8 and passes bytes through unchanged. Other types still raise TypeError. For example, an int key or value raises TypeError: expected bytes, int found.

Are these changes tested?

Yes. test_arbitrary_headers_in_flight_call_options runs once with str headers and once with bytes headers. The str case fails without the fix and passes with it.

Are there any user-facing changes?

Yes. FlightCallOptions now accepts both str and bytes for header keys and values. Existing callers that pass bytes get the same behavior.

Was AI used for this PR?

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

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.

[Python][Flight] Unexpected type for flight.FlightCallOptions kwargs "headers"

1 participant