Skip to content

Commit 65d8e84

Browse files
committed
fix
1 parent d60e259 commit 65d8e84

2 files changed

Lines changed: 17 additions & 364 deletions

File tree

src/a2a/server/request_handlers/rest_handler.py

Lines changed: 0 additions & 334 deletions
This file was deleted.

src/a2a/utils/helpers.py

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -338,36 +338,23 @@ def _get_actual_version(
338338
context = arg
339339
break
340340

341-
if context is not None:
342-
headers = context.state.get('headers', {})
343-
actual_version = headers.get(
344-
constants.VERSION_HEADER
345-
) or headers.get(constants.VERSION_HEADER.lower())
346-
347-
if not actual_version:
348-
return constants.PROTOCOL_VERSION_0_3
349-
350-
return str(actual_version)
351-
352-
# Fallback to Request
353-
request = kwargs.get('request')
354-
if request is None:
355-
for arg in args:
356-
if hasattr(arg, 'headers') and hasattr(arg, 'path_params'):
357-
request = arg
358-
break
359-
360-
if request is not None:
361-
headers = dict(request.headers)
362-
actual_version = headers.get(
363-
constants.VERSION_HEADER
364-
) or headers.get(constants.VERSION_HEADER.lower())
365-
366-
if not actual_version:
367-
return constants.PROTOCOL_VERSION_0_3
368-
return str(actual_version)
369-
370-
return expected_version
341+
if context is None:
342+
# If no context is found, we can't validate the version.
343+
# In a real scenario, this shouldn't happen for properly routed requests.
344+
# We default to the expected version to allow test call to proceed.
345+
return expected_version
346+
347+
headers = context.state.get('headers', {})
348+
# Header names are usually case-insensitive in most frameworks, but dict lookup is case-sensitive.
349+
# We check both standard and lowercase versions.
350+
actual_version = headers.get(
351+
constants.VERSION_HEADER
352+
) or headers.get(constants.VERSION_HEADER.lower())
353+
354+
if not actual_version:
355+
return constants.PROTOCOL_VERSION_0_3
356+
357+
return str(actual_version)
371358

372359
def _is_version_compatible(actual: str) -> bool:
373360
if actual == expected_version:

0 commit comments

Comments
 (0)