-
Notifications
You must be signed in to change notification settings - Fork 24
Description
The default for RequestConfiguration.headers is an instance of HeadersCollection. This is created at class definition time, meaning that all instances of RequestConfiguration share the same instance of HeadersCollection by default. This leads to conflict when different instances of RequestConfiguration add/remove headers.
kiota-python/packages/abstractions/kiota_abstractions/base_request_configuration.py
Lines 16 to 22 in 806c946
| @dataclass | |
| class RequestConfiguration(Generic[QueryParameters]): | |
| """ | |
| Configuration for the request such as headers, query parameters, and middleware options. | |
| """ | |
| # Request headers | |
| headers: HeadersCollection = HeadersCollection() |
Instead, a factory should be used so that a new instance is created:
from dataclasses import dataclass, field
from typing import Generic, Optional, TypeVar
QueryParameters = TypeVar("QueryParameters")
@dataclass
class RequestConfiguration(Generic[QueryParameters]):
headers: HeadersCollection = field(default_factory=HeadersCollection)
options: Optional[list[RequestOption]] = None
query_parameters: Optional[QueryParameters] = NoneThe same/similar issue also affects HeadersInspectionHandlerOption init param defaults.
kiota-python/packages/http/httpx/kiota_http/middleware/options/headers_inspection_handler_option.py
Lines 10 to 20 in 806c946
| class HeadersInspectionHandlerOption(RequestOption): | |
| """Config options for the HeaderInspectionHandler""" | |
| HEADERS_INSPECTION_HANDLER_OPTION_KEY = "HeadersInspectionHandlerOption" | |
| def __init__( | |
| self, | |
| inspect_request_headers: bool = True, | |
| inspect_response_headers: bool = True, | |
| request_headers: HeadersCollection = HeadersCollection(), | |
| response_headers: HeadersCollection = HeadersCollection(), |
Metadata
Metadata
Assignees
Labels
Type
Projects
Status