apache / apache/arrow

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

Open
#35,288 0 comments 1 reaction 0 assignees View on GitHub
Component: Python Type: bug
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 13h
Merged PRs (30d)
88

Description

### Describe the bug, including details regarding any error messages, version, and platform.

Affected Version: 11.0.0, OS: MacOS

When I was trying to build a call to flight server with custom header by `FlightCallOptions`, the kwargs`headers` is described as below
```
headers : List[Tuple[str, str]], optional
A list of arbitrary headers as key, value tuples
```
but it cannot accept str as key or value as below
```python
call_options = flight.FlightCallOptions(headers=[("a", "b")])

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pyarrow/_flight.pyx:142: in pyarrow._flight.FlightCallOptions.__init__
???
stringsource:48: in vector.from_py.__pyx_convert_vector_from_py_std_3a__3a_pair_3c_std_3a__3a_string_2c_std_3a__3a_string_3e___
???
stringsource:147: in pair.from_py.__pyx_convert_pair_from_py_std_3a__3a_string__and_std_3a__3a_string
???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

> ???
E TypeError: expected bytes, str found
```

For conviency, expected behavior should be:
```
headers : List[Union[Tuple[str, str],Tuple[str,bytes]], optional
A list of arbitrary headers as key, value tuples, bytes value if key ends with "-bin"
```

### Component(s)

Python

Contributor guide

Open the contributing guide

Research direction

Start at the FlightCallOptions initializer in pyarrow/_flight.pyx, around the conversion shown at line 142, and reproduce the documented headers example from the issue. Done means the documented tuple forms are accepted for string keys and byte values where appropriate, with the resulting behavior covered by a relevant test.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.