failed CONTEXT NO_PATCH UNSUBMITTED agent_error · 43 tool calls · 226 s · fastapi/fastapi
♻️ Do not accept underscore headers when using `convert_underscores=True` (the default) ## Pull Request <!-- Please start with a GitHub Discussion. Once a team member asks you to open a PR, create it and link the discussion here. Obvious typo fixes can be made in a PR without starting a discussion. --> Discussion: <!-- Link to the GitHub Discussion --> ## Description ♻️ Do not accept underscore headers when using `convert_underscores=True` (the default) This means it would only accept header names separated with hyphens by default, and to accept header names separated with underscores, an app would need to explicitly set `convert_underscores=False`. <!-- Write the description of your PR here --> ## AI Disclaimer <!-- If using AI, write here the prompt and model used --> <details> <summary>AI transcript</summary> <!-- Paste here the entire AI transcript --> </details> ## Checklist - [ ] This PR is an obvious typo fix, or it links to a GitHub Discussion for the proposed code change. - [ ] I added tests for the change. - [ ] The new or updated tests fail on the main branch and pass on this PR. - [ ] Coverage stays at 100%. - [ ] The documentation explains the change if needed.
| # | Tool | Arguments | Result |
|---|---|---|---|
| 1 | run_command | {
"command": "grep -rn \"convert_underscores\" . | head -20"
} | {"status": "ok", "stdout": "./docs/zh-hant/docs/tutorial/header-param-models.md:66:\u5728\u5c07 `convert_underscores` \u8a2d\u70ba `False` \u4e4b\u524d\uff0c\u8full{"status": "ok", "stdout": "./docs/zh-hant/docs/tutorial/header-param-models.md:66:\u5728\u5c07 `convert_underscores` \u8a2d\u70ba `False` \u4e4b\u524d\uff0c\u8acb\u6ce8\u610f\u6709\u4e9b HTTP \u4ee3\u7406\u8207\u4f3a\u670d\u5668\u4e0d\u5141\u8a31\u542b\u6709\u5e95\u7dda\u7684\u6a19\u982d\u3002\n./docs/zh-hant/docs/tutorial/header-params.md:47:\u82e5\u56e0\u67d0\u4e9b\u539f\u56e0\u9700\u8981\u505c\u7528\u5e95\u7dda\u81ea\u52d5\u8f49\u9023\u5b57\u865f\u7684\u884c\u70ba\uff0c\u5c07 `Header` \u7684 `convert_underscores` \u53c3\u6578\u8a2d\u70ba `False`\uff1a\n./docs/zh-hant/docs/tutorial/header-params.md:53:\u5728\u5c07 `convert_underscores` \u8a2d\u70ba `False` \u4e4b\u524d\uff0c\u8acb\u6ce8\u610f\u6709\u4e9b HTTP \u4ee3\u7406\u8207\u4f3a\u670d\u5668\u4e0d\u5141\u8a31\u4f7f\u7528\u5e36\u6709\u5e95\u7dda\u7684\u6a19\u982d\u3002\n./docs/ja/docs/tutorial/header-param-models.md:66:`convert_underscores` \u3092 `False` \u306b\u8a2d\u5b9a\u3059\u308b\u524d\u306b\u3001\u30a2\u30f3\u30c0\u30fc\u30b9\u30b3\u30a2\u3092\u542b\u3080\u30d8\u30c3\u30c0\u30fc\u306e\u4f7f\u7528\u3092\u7981\u6b62\u3057\u3066\u3044\u308b HTTP \u30d7\u30ed\u30ad\u30b7\u3084\u30b5\u30fc\u30d0\u30fc\u304c\u3042\u308b\u3053\u3068\u306b\u7559\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n./docs/ja/docs/tutorial/header-params.md:47:\u3082\u3057\u306a\u3093\u3089\u304b\u306e\u7406\u7531\u3067\u30a2\u30f3\u30c0\u30fc\u30b9\u30b3\u30a2\u304b\u3089\u30cf\u30a4\u30d5\u30f3\u3078\u306e\u81ea\u52d5\u5909\u63db\u3092\u7121\u52b9\u306b\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u5834\u5408\u306f\u3001`Header`\u306e\u30d1\u30e9\u30e1\u30fc\u30bf`convert_underscores`\u3092`False`\u306b\u8a2d\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044:\n./docs/ja/docs/tutorial/header-params.md:53:`convert_underscores`\u3092`False`\u306b\u8a2d\u5b9a\u3059\u308b\u524d\u306b\u3001HTTP\u30d7\u30ed\u30ad\u30b7\u3084\u30b5\u30fc\u30d0\u306e\u4e2d\u306b\u306f\u30a2\u30f3\u30c0\u30fc\u30b9\u30b3\u30a2\u3092\u542b\u3080\u30d8\u30c3\u30c0\u30fc\u |
| 2 | run_command | {
"command": "grep -rn \"convert_underscores\" fastapi | head -20"
} | {"status": "ok", "stdout": "fastapi/params.py:316: convert_underscores: bool = True,\nfastapi/params.py:352: self.convert_underscores = convert_underscores\nfasfull{"status": "ok", "stdout": "fastapi/params.py:316: convert_underscores: bool = True,\nfastapi/params.py:352: self.convert_underscores = convert_underscores\nfastapi/dependencies/utils.py:536: if not field_info.alias and getattr(field_info, \"convert_underscores\", None):\nfastapi/dependencies/utils.py:797: default_convert_underscores = True\nfastapi/dependencies/utils.py:803: # If headers are in a Pydantic model, the way to disable convert_underscores\nfastapi/dependencies/utils.py:804: # would be with Header(convert_underscores=False) at the Pydantic model level\nfastapi/dependencies/utils.py:805: default_convert_underscores = getattr(\nfastapi/dependencies/utils.py:806: first_field.field_info, \"convert_underscores\", True\nfastapi/dependencies/utils.py:817: # doesn't have a FieldInfo of type Header with the default convert_underscores=True\nfastapi/dependencies/utils.py:818: convert_underscores = getattr(\nfastapi/dependencies/utils.py:819: field.field_info, \"convert_underscores\", default_convert_underscores\nfastapi/dependencies/utils.py:821: if convert_underscores:\nfastapi/openapi/utils.py:128: default_convert_underscores = True\nfastapi/openapi/utils.py:132: default_convert_underscores = getattr(\nfastapi/openapi/utils.py:133: first_field.field_info, \"convert_underscores\", True\nfastapi/openapi/utils.py:148: convert_underscores = getattr(\nfastapi/openapi/utils.py:150: \"convert_underscores\",\nfastapi/openapi/utils.py:151: default_convert_underscores,\nfastapi/openapi/utils.py:156: and convert_underscores\nfastapi/param_functions.py:761: convert_underscores: Annotated[\n", "stderr": "", "exit_code": 0} |
| 3 | run_command | {
"command": "sed -n '520,550p' fastapi/dependencies/utils.py"
} | {"status": "ok", "stdout": " # It's a field_info, not a dependency\n if field_info is not None:\n # Handle field_info.in_\n if is_path_param:\n assert isinstancfull{"status": "ok", "stdout": " # It's a field_info, not a dependency\n if field_info is not None:\n # Handle field_info.in_\n if is_path_param:\n assert isinstance(field_info, params.Path), (\n f\"Cannot use `{field_info.__class__.__name__}` for path param\"\n f\" {param_name!r}\"\n )\n elif (\n isinstance(field_info, params.Param)\n and getattr(field_info, \"in_\", None) is None\n ):\n field_info.in_ = params.ParamTypes.query\n use_annotation_from_field_info = use_annotation\n if isinstance(field_info, params.Form):\n ensure_multipart_is_installed()\n if not field_info.alias and getattr(field_info, \"convert_underscores\", None):\n alias = param_name.replace(\"_\", \"-\")\n else:\n alias = field_info.alias or param_name\n field_info.alias = alias\n field = create_model_field(\n name=param_name,\n type_=use_annotation_from_field_info,\n default=field_info.default,\n alias=alias,\n field_info=field_info,\n )\n if is_path_param:\n assert is_scalar_field(field=field), (\n \"Path params must be of one of the supported types\"\n", "stderr": "", "exit_code": 0} |
| 4 | run_command | {
"command": "sed -n '780,830p' fastapi/dependencies/utils.py"
} | {"status": "ok", "stdout": " return deepcopy(field.default)\n return value\n\n\ndef request_params_to_args(\n fields: Sequence[ModelField],\n received_params: Mfull{"status": "ok", "stdout": " return deepcopy(field.default)\n return value\n\n\ndef request_params_to_args(\n fields: Sequence[ModelField],\n received_params: Mapping[str, Any] | QueryParams | Headers,\n) -> tuple[dict[str, Any], list[Any]]:\n values: dict[str, Any] = {}\n errors: list[dict[str, Any]] = []\n\n if not fields:\n return values, errors\n\n first_field = fields[0]\n fields_to_extract = fields\n single_not_embedded_field = False\n default_convert_underscores = True\n if len(fields) == 1 and lenient_issubclass(\n first_field.field_info.annotation, BaseModel\n ):\n fields_to_extract = get_cached_model_fields(first_field.field_info.annotation)\n single_not_embedded_field = True\n # If headers are in a Pydantic model, the way to disable convert_underscores\n # would be with Header(convert_underscores=False) at the Pydantic model level\n default_convert_underscores = getattr(\n first_field.field_info, \"convert_underscores\", True\n )\n\n params_to_process: dict[str, Any] = {}\n\n processed_keys = set()\n\n for field in fields_to_extract:\n alias = None\n if isinstance(received_params, Headers):\n # Handle fields extracted from a Pydantic Model for a header, each field\n # doesn't have a FieldInfo of type Header with the default convert_underscores=True\n convert_underscores = getattr(\n field.field_info, \"convert_underscores\", default_convert_underscores\n )\n if convert_underscores:\n alias = get_validation_alias(field)\n if alias == field.name:\n alias = alias.replace(\"_\", \"-\")\n value = _get_multidict_value(field, received_params, alias=alias)\n if value is not None:\n params_to_process[get_validation_alias(field)] = value\n processed_keys.add(alias or get_validation_ |
| 5 | run_command | {
"command": "python3 - <<'PY'\nfrom fastapi import FastAPI, Header, TestClient\nfrom fastapi.testclient import TestClient\n\napp = FastAPI()\n\n@app.get(\"/\")\nasync def read_root(x: str = Header(alias=\"x-header\")):\n return {\"x\": x}\n\n@app.get(\"/underscore\")\nasync def read_underscore(x: str = Header()):\n return {\"x\": x}\n\nclient = TestClient(app)\n\n# Test 1: Normal hyphenated header (should work)\nresp = client.get(\"/underscore\", headers={\"x-header\": \"foo\"})\nprint(f\"Test 1: {resp.json()} - Expected: {'x': 'foo'}\")\n\n# Test 2: Underscore header when convert_underscores=True (default)\n# Current behavior: accepts 'x_header' and converts it to 'x-header'\nresp = client.get(\"/underscore\", headers={\"x_header\": \"bar\"})\nprint(f\"Test 2: {resp.json()} - Expected: {'x': 'bar'} (Current), but should be 422 (New)\")\n\n# Test 3: Underscore header when convert_underscores=False\n@app.get(\"/underscore_false\")\nasync def read_underscore_false(x: str = Header(convert_underscores=False)):\n return {\"x\": x}\n\nresp = client.get(\"/underscore_false\", headers={\"x_header\": \"baz\"})\nprint(f\"Test 3: {resp.json()} - Expected: {'x': 'baz'}\")\nPY\n"
} | {"status": "error", "error_type": "CommandError", "error_message": "Traceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\nImportError: canfull{"status": "error", "error_type": "CommandError", "error_message": "Traceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\nImportError: cannot import name 'TestClient' from 'fastapi' (/private/workspace/fastapi/__init__.py)\n", "details": {"stdout": "", "stderr": "Traceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\nImportError: cannot import name 'TestClient' from 'fastapi' (/private/workspace/fastapi/__init__.py)\n", "exit_code": 1}} |
| 6 | run_command | {
"command": "python3 - <<'PY'\nfrom fastapi import FastAPI, Header\nfrom fastapi.testclient import TestClient\n\napp = FastAPI()\n\n@app.get(\"/underscore\")\nasync def read_underscore(x: str = Header()):\n return {\"x\": x}\n\nclient = TestClient(app)\n\n# Test 2: Underscore header when convert_underscores=True (default)\nresp = client.get(\"/underscore\", headers={\"x_header\": \"bar\"})\nprint(f\"Test 2: {resp.json()} - Expected: {'x': 'bar'} (Current)\")\nPY\n"
} | {"status": "error", "error_type": "CommandError", "error_message": "Traceback (most recent call last):\n File \"<stdin>\", line 14, in <module>\nValueError: Invfull{"status": "error", "error_type": "CommandError", "error_message": "Traceback (most recent call last):\n File \"<stdin>\", line 14, in <module>\nValueError: Invalid format specifier ' 'bar'' for object of type 'str'\n", "details": {"stdout": "", "stderr": "Traceback (most recent call last):\n File \"<stdin>\", line 14, in <module>\nValueError: Invalid format specifier ' 'bar'' for object of type 'str'\n", "exit_code": 1}} |
| 7 | run_command | {
"command": "python3 - <<'PY'\nfrom fastapi import FastAPI, Header\nfrom fastapi.testclient import TestClient\n\napp = FastAPI()\n\n@app.get(\"/underscore\")\nasync def read_underscore(x: str = Header()):\n return {\"x\": x}\n\nclient = TestClient(app)\n\n# Test 2: Underscore header when convert_underscores=True (default)\nresp = client.get(\"/underscore\", headers={\"x_header\": \"bar\"})\nprint(f\"Test 2: {resp.json()}\")\nPY\n"
} | {"status": "ok", "stdout": "Test 2: {'detail': [{'type': 'missing', 'loc': ['header', 'x'], 'msg': 'Field required', 'input': None}]}\n", "stderr": "", "exit_cofull{"status": "ok", "stdout": "Test 2: {'detail': [{'type': 'missing', 'loc': ['header', 'x'], 'msg': 'Field required', 'input': None}]}\n", "stderr": "", "exit_code": 0} |
| 8 | run_command | {
"command": "python3 - <<'PY'\nfrom fastapi import FastAPI, Header\nfrom fastapi.testclient import TestClient\n\napp = FastAPI()\n\n@app.get(\"/underscore\")\nasync def read_underscore(x: str = Header()):\n return {\"x\": x}\n\nclient = TestClient(app)\n\n# Test 2: Underscore header when convert_underscores=True (default)\n# If x is the param name, it should look for 'x' or 'x-header' (if it was x_header)\n# Wait, if the param name is 'x', then it looks for 'x' header.\n# If the param name is 'x_header', it should look for 'x-header'.\n\napp2 = FastAPI()\n@app2.get(\"/underscore2\")\nasync def read_underscore2(x_header: str = Header()):\n return {\"x_header\": x_header}\n\nclient2 = TestClient(app2)\nresp = client2.get(\"/underscore2\", headers={\"x_header\": \"bar\"})\nprint(f\"Test 2: {resp.json()}\")\nPY\n"
} | {"status": "ok", "stdout": "Test 2: {'detail': [{'type': 'missing', 'loc': ['header', 'x-header'], 'msg': 'Field required', 'input': None}]}\n", "stderr": "", "full{"status": "ok", "stdout": "Test 2: {'detail': [{'type': 'missing', 'loc': ['header', 'x-header'], 'msg': 'Field required', 'input': None}]}\n", "stderr": "", "exit_code": 0} |
| 9 | run_command | {
"command": "python3 - <<'PY'\nfrom fastapi import FastAPI, Header\nfrom fastapi.testclient import TestClient\n\napp = FastAPI()\n\n@app.get(\"/underscore\")\nasync def read_underscore(x_header: str = Header()):\n return {\"x_header\": x_header}\n\nclient = TestClient(app)\n\n# Test: Underscore header when convert_underscores=True (default)\n# It should look for 'x-header'\nresp = client.get(\"/underscore\", headers={\"x-header\": \"bar\"})\nprint(f\"Hyphen header: {resp.json()}\")\n\n# It should NOT accept 'x_header'\nresp = client.get(\"/underscore\", headers={\"x_header\": \"baz\"})\nprint(f\"Underscore header: {resp.json()}\")\nPY\n"
} | {"status": "ok", "stdout": "Hyphen header: {'x_header': 'bar'}\nUnderscore header: {'detail': [{'type': 'missing', 'loc': ['header', 'x-header'], 'msg': 'Field full{"status": "ok", "stdout": "Hyphen header: {'x_header': 'bar'}\nUnderscore header: {'detail': [{'type': 'missing', 'loc': ['header', 'x-header'], 'msg': 'Field required', 'input': None}]}\n", "stderr": "", "exit_code": 0} |
| 10 | run_command | {
"command": "python3 - <<'PY'\nfrom fastapi import FastAPI, Header\nfrom fastapi.testclient import TestClient\nfrom pydantic import BaseModel\n\napp = FastAPI()\n\nclass HeaderModel(BaseModel):\n x_header: str\n\n@app.get(\"/model\")\nasync def read_model(headers: HeaderModel = Header()):\n return {\"headers\": headers}\n\nclient = TestClient(app)\n\n# Test: Underscore header when convert_underscores=True (default)\n# It should look for 'x-header'\nresp = client.get(\"/model\", headers={\"x-header\": \"bar\"})\nprint(f\"Hyphen header: {resp.json()}\")\n\n# It should NOT accept 'x_header'\nresp = client.get(\"/model\", headers={\"x_header\": \"baz\"})\nprint(f\"Underscore header: {resp.json()}\")\nPY\n"
} | {"status": "ok", "stdout": "Hyphen header: {'headers': {'x_header': 'bar'}}\nUnderscore header: {'headers': {'x_header': 'baz'}}\n", "stderr": "", "exit_code": full{"status": "ok", "stdout": "Hyphen header: {'headers': {'x_header': 'bar'}}\nUnderscore header: {'headers': {'x_header': 'baz'}}\n", "stderr": "", "exit_code": 0} |
| 11 | run_command | {
"command": "sed -n '790,825p' fastapi/dependencies/utils.py"
} | {"status": "ok", "stdout": "\n if not fields:\n return values, errors\n\n first_field = fields[0]\n fields_to_extract = fields\n single_not_embedded_field = Falfull{"status": "ok", "stdout": "\n if not fields:\n return values, errors\n\n first_field = fields[0]\n fields_to_extract = fields\n single_not_embedded_field = False\n default_convert_underscores = True\n if len(fields) == 1 and lenient_issubclass(\n first_field.field_info.annotation, BaseModel\n ):\n fields_to_extract = get_cached_model_fields(first_field.field_info.annotation)\n single_not_embedded_field = True\n # If headers are in a Pydantic model, the way to disable convert_underscores\n # would be with Header(convert_underscores=False) at the Pydantic model level\n default_convert_underscores = getattr(\n first_field.field_info, \"convert_underscores\", True\n )\n\n params_to_process: dict[str, Any] = {}\n\n processed_keys = set()\n\n for field in fields_to_extract:\n alias = None\n if isinstance(received_params, Headers):\n # Handle fields extracted from a Pydantic Model for a header, each field\n # doesn't have a FieldInfo of type Header with the default convert_underscores=True\n convert_underscores = getattr(\n field.field_info, \"convert_underscores\", default_convert_underscores\n )\n if convert_underscores:\n alias = get_validation_alias(field)\n if alias == field.name:\n alias = alias.replace(\"_\", \"-\")\n value = _get_multidict_value(field, received_params, alias=alias)\n", "stderr": "", "exit_code": 0} |
| 12 | run_command | {
"command": "python3 - <<'PY'\nfrom fastapi import FastAPI, Header\nfrom fastapi.testclient import TestClient\nfrom pydantic import BaseModel\n\napp = FastAPI()\n\nclass HeaderModel(BaseModel):\n x_header: str\n\n@app.get(\"/model\")\nasync def read_model(headers: HeaderModel = Header(convert_underscores=False)):\n return {\"headers\": headers}\n\nclient = TestClient(app)\n\n# Test: Underscore header when convert_underscores=False\nresp = client.get(\"/model\", headers={\"x_header\": \"baz\"})\nprint(f\"Underscore header (convert_underscores=False): {resp.json()}\")\n\n# It should NOT accept 'x-header'\nresp = client.get(\"/model\", headers={\"x-header\": \"bar\"})\nprint(f\"Hyphen header (convert_underscores=False): {resp.json()}\")\nPY\n"
} | {"status": "ok", "stdout": "Underscore header (convert_underscores=False): {'headers': {'x_header': 'baz'}}\nHyphen header (convert_underscores=False): {'detailfull{"status": "ok", "stdout": "Underscore header (convert_underscores=False): {'headers': {'x_header': 'baz'}}\nHyphen header (convert_underscores=False): {'detail': [{'type': 'missing', 'loc': ['header', 'x_header'], 'msg': 'Field required', 'input': {'host': 'testserver', 'accept': '*/*', 'accept-encoding': 'gzip, deflate', 'connection': 'keep-alive', 'user-agent': 'testclient', 'x-header': 'bar'}}]}\n", "stderr": "", "exit_code": 0} |
| 13 | run_command | {
"command": "python3 - <<'PY'\nfrom fastapi import FastAPI, Header\nfrom fastapi.testclient import TestClient\nfrom pydantic import BaseModel\n\napp = FastAPI()\n\nclass HeaderModel(BaseModel):\n x_header: str\n\n@app.get(\"/model\")\nasync def read_model(headers: HeaderModel = Header()):\n return {\"headers\": headers}\n\nclient = TestClient(app)\n\n# Test: Underscore header when convert_underscores=True (default)\n# Current behavior: accepts 'x_header'\nresp = client.get(\"/model\", headers={\"x_header\": \"baz\"})\nprint(f\"Underscore header: {resp.json()}\")\n\n# Current behavior: accepts 'x-header'\nresp = client.get(\"/model\", headers={\"x-header\": \"bar\"})\nprint(f\"Hyphen header: {resp.json()}\")\nPY\n"
} | {"status": "ok", "stdout": "Underscore header: {'headers': {'x_header': 'baz'}}\nHyphen header: {'headers': {'x_header': 'bar'}}\n", "stderr": "", "exit_code": full{"status": "ok", "stdout": "Underscore header: {'headers': {'x_header': 'baz'}}\nHyphen header: {'headers': {'x_header': 'bar'}}\n", "stderr": "", "exit_code": 0} |
| 14 | run_command | {
"command": "sed -n '800,825p' fastapi/dependencies/utils.py"
} | {"status": "ok", "stdout": " ):\n fields_to_extract = get_cached_model_fields(first_field.field_info.annotation)\n single_not_embedded_field = True\n # If headefull{"status": "ok", "stdout": " ):\n fields_to_extract = get_cached_model_fields(first_field.field_info.annotation)\n single_not_embedded_field = True\n # If headers are in a Pydantic model, the way to disable convert_underscores\n # would be with Header(convert_underscores=False) at the Pydantic model level\n default_convert_underscores = getattr(\n first_field.field_info, \"convert_underscores\", True\n )\n\n params_to_process: dict[str, Any] = {}\n\n processed_keys = set()\n\n for field in fields_to_extract:\n alias = None\n if isinstance(received_params, Headers):\n # Handle fields extracted from a Pydantic Model for a header, each field\n # doesn't have a FieldInfo of type Header with the default convert_underscores=True\n convert_underscores = getattr(\n field.field_info, \"convert_underscores\", default_convert_underscores\n )\n if convert_underscores:\n alias = get_validation_alias(field)\n if alias == field.name:\n alias = alias.replace(\"_\", \"-\")\n value = _get_multidict_value(field, received_params, alias=alias)\n", "stderr": "", "exit_code": 0} |
| 15 | run_command | {
"command": "python3 - <<'PY'\nfrom fastapi import FastAPI, Header\nfrom fastapi.testclient import TestClient\nfrom pydantic import BaseModel\n\napp = FastAPI()\n\nclass HeaderModel(BaseModel):\n x_header: str\n\n@app.get(\"/model\")\nasync def read_model(headers: HeaderModel = Header()):\n return {\"headers\": headers}\n\nclient = TestClient(app)\n\n# We want to see if it's because _get_multidict_value is too lenient\n# Let's see what _get_multidict_value does.\nPY\n"
} | {"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0} |
| 16 | run_command | {
"command": "grep -n \"_get_multidict_value\" fastapi/dependencies/utils.py"
} | {"status": "ok", "stdout": "753:def _get_multidict_value(\n825: value = _get_multidict_value(field, received_params, alias=alias)\n853: value = _get_multidict_vfull{"status": "ok", "stdout": "753:def _get_multidict_value(\n825: value = _get_multidict_value(field, received_params, alias=alias)\n853: value = _get_multidict_value(field, received_params)\n919: value = _get_multidict_value(field, received_body)\n", "stderr": "", "exit_code": 0} |
| 17 | run_command | {
"command": "sed -n '753,780p' fastapi/dependencies/utils.py"
} | {"status": "ok", "stdout": "def _get_multidict_value(\n field: ModelField, values: Mapping[str, Any], alias: str | None = None\n) -> Any:\n alias = alias or getfull{"status": "ok", "stdout": "def _get_multidict_value(\n field: ModelField, values: Mapping[str, Any], alias: str | None = None\n) -> Any:\n alias = alias or get_validation_alias(field)\n if (\n (not _is_json_field(field))\n and field_annotation_is_sequence(field.field_info.annotation)\n and isinstance(values, (ImmutableMultiDict, Headers))\n ):\n value = values.getlist(alias)\n else:\n value = values.get(alias, None)\n if (\n value is None\n or (\n isinstance(field.field_info, params.Form)\n and isinstance(value, str) # For type checks\n and value == \"\"\n )\n or (\n field_annotation_is_sequence(field.field_info.annotation)\n and len(value) == 0\n )\n ):\n if field.field_info.is_required():\n return\n else:\n return deepcopy(field.default)\n", "stderr": "", "exit_code": 0} |
| 18 | run_command | {
"command": "sed -n '781,800p' fastapi/dependencies/utils.py"
} | {"status": "ok", "stdout": " return value\n\n\ndef request_params_to_args(\n fields: Sequence[ModelField],\n received_params: Mapping[str, Any] | QueryParams | full{"status": "ok", "stdout": " return value\n\n\ndef request_params_to_args(\n fields: Sequence[ModelField],\n received_params: Mapping[str, Any] | QueryParams | Headers,\n) -> tuple[dict[str, Any], list[Any]]:\n values: dict[str, Any] = {}\n errors: list[dict[str, Any]] = []\n\n if not fields:\n return values, errors\n\n first_field = fields[0]\n fields_to_extract = fields\n single_not_embedded_field = False\n default_convert_underscores = True\n if len(fields) == 1 and lenient_issubclass(\n first_field.field_info.annotation, BaseModel\n ):\n", "stderr": "", "exit_code": 0} |
| 19-20 ×2 | run_command | {
"command": "python3 - <<'PY'\nfrom fastapi import FastAPI, Header\nfrom fastapi.testclient import TestClient\nfrom pydantic import BaseModel\n\napp = FastAPI()\n\nclass HeaderModel(BaseModel):\n x_header: str\n\n@app.get(\"/model\")\nasync def read_model(headers: HeaderModel = Header()):\n return {\"headers\": headers}\n\nclient = TestClient(app)\n\n# Current behavior: accepts 'x_header'\nresp = client.get(\"/model\", headers={\"x_header\": \"baz\"})\nprint(f\"Underscore header: {resp.json()}\")\n\n# Current behavior: accepts 'x-header'\nresp = client.get(\"/model\", headers={\"x-header\": \"bar\"})\nprint(f\"Hyphen header: {resp.json()}\")\nPY\n"
} | {"status": "ok", "stdout": "Underscore header: {'headers': {'x_header': 'baz'}}\nHyphen header: {'headers': {'x_header': 'bar'}}\n", "stderr": "", "exit_code": full{"status": "ok", "stdout": "Underscore header: {'headers': {'x_header': 'baz'}}\nHyphen header: {'headers': {'x_header': 'bar'}}\n", "stderr": "", "exit_code": 0} |
| 21 | run_command | {
"command": "python3 - <<'PY'\nfrom fastapi import FastAPI, Header\nfrom fastapi.testclient import TestClient\nfrom pydantic import BaseModel\n\napp = FastAPI()\n\nclass HeaderModel(BaseModel):\n x_header: str\n\n@app.get(\"/model\")\nasync def read_model(headers: HeaderModel = Header()):\n return {\"headers\": headers}\n\nclient = TestClient(app)\n\n# We want to see if it's because of how Pydantic handles aliases.\n# In HeaderModel, x_header has no alias.\n# In request_params_to_args:\n# for field in fields_to_extract:\n# alias = None\n# if isinstance(received_params, Headers):\n# convert_underscores = getattr(field.field_info, \"convert_underscores\", default_convert_underscores)\n# if convert_underscores:\n# alias = get_validation_alias(field)\n# if alias == field.name:\n# alias = alias.replace(\"_\", \"-\")\n# value = _get_multidict_value(field, received_params, alias=alias)\n#\n# If convert_underscores=True, alias becomes 'x-header'.\n# Then _get_multidict_value(field, received_params, alias='x-header') is called.\n# Inside _get_multidict_value:\n# alias = alias or get_validation_alias(field) # alias is 'x-header'\n# value = values.get(alias, None) # values.get('x-header', None)\n#\n# Wait, if received_params is a Headers object (which is a CaseInsensitiveDict),\n# and we call .get('x-header'), it should return the value for 'x-header'.\n# But why does it also return the value for 'x_header'?\n#\n# Let's check what fastapi.dependencies.utils.Headers is.\nPY\n"
} | {"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0} |
| 22 | run_command | {
"command": "grep -n \"class Headers\" fastapi/dependencies/utils.py | head -10"
} | {"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0} |
| 23 | run_command | {
"command": "grep -rn \"class Headers\" fastapi | head -10"
} | {"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0} |
| 24 | run_command | {
"command": "grep -rn \"from .* import Headers\" fastapi | head -10"
} | {"status": "ok", "stdout": "fastapi/datastructures.py:15:from starlette.datastructures import Headers as Headers # noqa: F401\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "fastapi/datastructures.py:15:from starlette.datastructures import Headers as Headers # noqa: F401\n", "stderr": "", "exit_code": 0} |
| 25 | run_command | {
"command": "python3 - <<'PY'\nfrom starlette.datastructures import Headers\nheaders = Headers({\"x_header\": \"baz\"})\nprint(f\"headers.get('x-header'): {headers.get('x-header')}\")\nprint(f\"headers.get('x_header'): {headers.get('x_header')}\")\nPY\n"
} | {"status": "ok", "stdout": "headers.get('x-header'): None\nheaders.get('x_header'): baz\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "headers.get('x-header'): None\nheaders.get('x_header'): baz\n", "stderr": "", "exit_code": 0} |
| 26 | run_command | {
"command": "python3 - <<'PY'\nfrom fastapi import FastAPI, Header\nfrom fastapi.testclient import TestClient\nfrom pydantic import BaseModel\n\napp = FastAPI()\n\nclass HeaderModel(BaseModel):\n x_header: str\n\n@app.get(\"/model\")\nasync def read_model(headers: HeaderModel = Header()):\n return {\"headers\": headers}\n\nclient = TestClient(app)\n\n# Current behavior: accepts 'x_header'\nresp = client.get(\"/model\", headers={\"x_header\": \"baz\"})\nprint(f\"Underscore header: {resp.json()}\")\nPY\n"
} | {"status": "ok", "stdout": "Underscore header: {'headers': {'x_header': 'baz'}}\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "Underscore header: {'headers': {'x_header': 'baz'}}\n", "stderr": "", "exit_code": 0} |
| 27 | run_command | {
"command": "python3 - <<'PY'\nfrom fastapi import FastAPI, Header\nfrom fastapi.testclient import TestClient\nfrom pydantic import BaseModel\n\napp = FastAPI()\n\nclass HeaderModel(BaseModel):\n x_header: str\n\n@app.get(\"/model\")\nasync def read_model(headers: HeaderModel = Header()):\n return {\"headers\": headers}\n\nclient = TestClient(app)\n\n# Current behavior: accepts 'x-header'\nresp = client.get(\"/model\", headers={\"x-header\": \"bar\"})\nprint(f\"Hyphen header: {resp.json()}\")\nPY\n"
} | {"status": "ok", "stdout": "Hyphen header: {'headers': {'x_header': 'bar'}}\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "Hyphen header: {'headers': {'x_header': 'bar'}}\n", "stderr": "", "exit_code": 0} |
| 28 | run_command | {
"command": "python3 - <<'PY'\nfrom fastapi import FastAPI, Header\nfrom fastapi.testclient import TestClient\nfrom pydantic import BaseModel\n\napp = FastAPI()\n\nclass HeaderModel(BaseModel):\n x_header: str\n\n@app.get(\"/model\")\nasync def read_model(headers: HeaderModel = Header()):\n return {\"headers\": headers}\n\nclient = TestClient(app)\n\n# Let's see what happens if we use a different name in the model\nclass HeaderModel2(BaseModel):\n x_header_2: str\n\n@app.get(\"/model2\")\nasync def read_model2(headers: HeaderModel2 = Header()):\n return {\"headers\": headers}\n\nresp = client.get(\"/model2\", headers={\"x_header_2\": \"baz\"})\nprint(f\"Underscore header 2: {resp.json()}\")\nPY\n"
} | {"status": "ok", "stdout": "Underscore header 2: {'headers': {'x_header_2': 'baz'}}\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "Underscore header 2: {'headers': {'x_header_2': 'baz'}}\n", "stderr": "", "exit_code": 0} |
| 29 | run_command | {
"command": "python3 - <<'PY'\nfrom fastapi import FastAPI, Header\nfrom fastapi.testclient import TestClient\nfrom pydantic import BaseModel\n\napp = FastAPI()\n\nclass HeaderModel(BaseModel):\n x_header: str\n\n@app.get(\"/model\")\nasync def read_model(headers: HeaderModel = Header()):\n return {\"headers\": headers}\n\nclient = TestClient(app)\n\n# If convert_underscores=True, it should look for 'x-header'.\n# If it finds 'x-header', it's good.\n# If it doesn't find 'x-header', it should NOT look for 'x_header'.\n# But currently it seems to accept 'x_header'.\n# Let's check if it's because of Pydantic's validation.\n# In request_params_to_args:\n# value = _get_multidict_value(field, received_params, alias=alias)\n# if value is not None:\n# params_to_process[get_validation_alias(field)] = value\n#\n# If alias='x-header' and received_params={'x_header': 'baz'},\n# _get_multidict_value(field, received_params, alias='x-header') should return None.\n# Then params_to_process will be empty.\n# Then it will go to:\n# for key in received_params.keys():\n# if key in params_to_process:\n# ...\n#\n# Wait, I missed the rest of request_params_to_args.\nPY\n"
} | {"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0} |
| 30 | run_command | {
"command": "sed -n '826,860p' fastapi/dependencies/utils.py"
} | {"status": "ok", "stdout": " if value is not None:\n params_to_process[get_validation_alias(field)] = value\n processed_keys.add(alias or get_validation_alias(ffull{"status": "ok", "stdout": " if value is not None:\n params_to_process[get_validation_alias(field)] = value\n processed_keys.add(alias or get_validation_alias(field))\n\n for key in received_params.keys():\n if key not in processed_keys:\n if isinstance(received_params, (ImmutableMultiDict, Headers)):\n value = received_params.getlist(key)\n if isinstance(value, list) and (len(value) == 1):\n params_to_process[key] = value[0]\n else:\n params_to_process[key] = value\n else:\n params_to_process[key] = received_params.get(key)\n\n if single_not_embedded_field:\n field_info = first_field.field_info\n assert isinstance(field_info, params.Param), (\n \"Params must be subclasses of Param\"\n )\n loc: tuple[str, ...] = (field_info.in_.value,)\n v_, errors_ = _validate_value_with_model_field(\n field=first_field, value=params_to_process, values=values, loc=loc\n )\n return {first_field.name: v_}, errors_\n\n for field in fields:\n value = _get_multidict_value(field, received_params)\n field_info = field.field_info\n assert isinstance(field_info, params.Param), (\n \"Params must be subclasses of Param\"\n )\n loc = (field_info.in_.value, get_validation_alias(field))\n v_, errors_ = _validate_value_with_model_field(\n field=field, value=value, values=values, loc=loc\n", "stderr": "", "exit_code": 0} |
| 31 | run_command | {
"command": "python3 - <<'PY'\nfrom fastapi import FastAPI, Header\nfrom fastapi.testclient import TestClient\nfrom pydantic import BaseModel\n\napp = FastAPI()\n\nclass HeaderModel(BaseModel):\n x_header: str\n\n@app.get(\"/model\")\nasync def read_model(headers: HeaderModel = Header()):\n return {\"headers\": headers}\n\nclient = TestClient(app)\n\n# If we send 'x_header', it's not in processed_keys (which contains 'x-header').\n# So it's added to params_to_process['x_header'] = 'baz'.\n# Then Pydantic validates params_to_process = {'x_header': 'baz'} against HeaderModel.\n# Pydantic sees 'x_header' matches the field name, so it's accepted.\nresp = client.get(\"/model\", headers={\"x_header\": \"baz\"})\nprint(f\"Underscore header: {resp.json()}\")\nPY\n"
} | {"status": "ok", "stdout": "Underscore header: {'headers': {'x_header': 'baz'}}\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "Underscore header: {'headers': {'x_header': 'baz'}}\n", "stderr": "", "exit_code": 0} |
| 32 | run_command | {
"command": "python3 - <<'PY'\nfrom fastapi import FastAPI, Header\nfrom fastapi.testclient import TestClient\nfrom pydantic import BaseModel\n\napp = FastAPI()\n\nclass HeaderModel(BaseModel):\n x_header: str\n\n@app.get(\"/model\")\nasync def read_model(headers: HeaderModel = Header()):\n return {\"headers\": headers}\n\nclient = TestClient(app)\n\n# If we send 'x-header', it's in processed_keys.\n# It's added to params_to_process['x_header'] = 'bar'.\n# Then Pydantic validates params_to_process = {'x_header': 'bar'} against HeaderModel.\nresp = client.get(\"/model\", headers={\"x-header\": \"bar\"})\nprint(f\"Hyphen header: {resp.json()}\")\nPY\n"
} | {"status": "ok", "stdout": "Hyphen header: {'headers': {'x_header': 'bar'}}\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "Hyphen header: {'headers': {'x_header': 'bar'}}\n", "stderr": "", "exit_code": 0} |
| 33 | run_command | {
"command": "python3 - <<'PY'\nfrom fastapi import FastAPI, Header\nfrom fastapi.testclient import TestClient\nfrom pydantic import BaseModel\n\napp = FastAPI()\n\nclass HeaderModel(BaseModel):\n x_header: str\n\n@app.get(\"/model\")\nasync def read_model(headers: HeaderModel = Header()):\n return {\"headers\": headers}\n\nclient = TestClient(app)\n\n# If we send both 'x-header' and 'x_header'\nresp = client.get(\"/model\", headers={\"x-header\": \"bar\", \"x_header\": \"baz\"})\nprint(f\"Both headers: {resp.json()}\")\nPY\n"
} | {"status": "ok", "stdout": "Both headers: {'headers': {'x_header': 'baz'}}\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "Both headers: {'headers': {'x_header': 'baz'}}\n", "stderr": "", "exit_code": 0} |
| 34 | run_command | {
"command": "python3 - <<'PY'\nfrom fastapi import FastAPI, Header\nfrom fastapi.testclient import TestClient\nfrom pydantic import BaseModel\n\napp = FastAPI()\n\nclass HeaderModel(BaseModel):\n x_header: str\n\n@app.get(\"/model\")\nasync def read_model(headers: HeaderModel = Header()):\n return {\"headers\": headers}\n\nclient = TestClient(app)\n\n# If we send 'x_header', it's added to params_to_process['x_header'] = 'baz'.\n# But we want to prevent this if convert_underscores=True.\n# The loop that adds remaining keys:\n# for key in received_params.keys():\n# if key not in processed_keys:\n# ...\n# params_to_process[key] = value\n#\n# We should check if 'key' contains underscores and convert_underscores is True.\nPY\n"
} | {"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0} |
| 35 | run_command | {
"command": "sed -n '826,840p' fastapi/dependencies/utils.py"
} | {"status": "ok", "stdout": " if value is not None:\n params_to_process[get_validation_alias(field)] = value\n processed_keys.add(alias or get_validation_alias(ffull{"status": "ok", "stdout": " if value is not None:\n params_to_process[get_validation_alias(field)] = value\n processed_keys.add(alias or get_validation_alias(field))\n\n for key in received_params.keys():\n if key not in processed_keys:\n if isinstance(received_params, (ImmutableMultiDict, Headers)):\n value = received_params.getlist(key)\n if isinstance(value, list) and (len(value) == 1):\n params_to_process[key] = value[0]\n else:\n params_to_process[key] = value\n else:\n params_to_process[key] = received_params.get(key)\n\n", "stderr": "", "exit_code": 0} |
| 36 | run_command | {
"command": "python3 - <<'PY'\nfrom fastapi import FastAPI, Header\nfrom fastapi.testclient import TestClient\nfrom pydantic import BaseModel\n\napp = FastAPI()\n\nclass HeaderModel(BaseModel):\n x_header: str\n\n@app.get(\"/model\")\nasync def read_model(headers: HeaderModel = Header()):\n return {\"headers\": headers}\n\nclient = TestClient(app)\n\n# If we send 'x_header', it's added to params_to_process['x_header'] = 'baz'.\n# We want to avoid this if convert_underscores=True.\n# But wait, what if the user explicitly set convert_underscores=False?\n# Then it SHOULD be accepted.\n# The current loop doesn't know about convert_underscores.\nPY\n"
} | {"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0} |
| 37 | run_command | {
"command": "sed -n '800,825p' fastapi/dependencies/utils.py"
} | {"status": "ok", "stdout": " ):\n fields_to_extract = get_cached_model_fields(first_field.field_info.annotation)\n single_not_embedded_field = True\n # If headefull{"status": "ok", "stdout": " ):\n fields_to_extract = get_cached_model_fields(first_field.field_info.annotation)\n single_not_embedded_field = True\n # If headers are in a Pydantic model, the way to disable convert_underscores\n # would be with Header(convert_underscores=False) at the Pydantic model level\n default_convert_underscores = getattr(\n first_field.field_info, \"convert_underscores\", True\n )\n\n params_to_process: dict[str, Any] = {}\n\n processed_keys = set()\n\n for field in fields_to_extract:\n alias = None\n if isinstance(received_params, Headers):\n # Handle fields extracted from a Pydantic Model for a header, each field\n # doesn't have a FieldInfo of type Header with the default convert_underscores=True\n convert_underscores = getattr(\n field.field_info, \"convert_underscores\", default_convert_underscores\n )\n if convert_underscores:\n alias = get_validation_alias(field)\n if alias == field.name:\n alias = alias.replace(\"_\", \"-\")\n value = _get_multidict_value(field, received_params, alias=alias)\n", "stderr": "", "exit_code": 0} |
| 38 | run_command | {
"command": "python3 - <<'PY'\nfrom fastapi import FastAPI, Header\nfrom fastapi.testclient import TestClient\nfrom pydantic import BaseModel\n\napp = FastAPI()\n\nclass HeaderModel(BaseModel):\n x_header: str\n\n@app.get(\"/model\")\nasync def read_model(headers: HeaderModel = Header()):\n return {\"headers\": headers}\n\nclient = TestClient(app)\n\n# If we send 'x_header', it's added to params_to_process['x_header'] = 'baz'.\n# We should only add it if it doesn't contain underscores, OR if convert_underscores is False.\n# But the loop is over all keys in received_params.\n# We need to know if we are in a context where convert_underscores is True.\nPY\n"
} | {"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0} |
| 39 | run_command | {
"command": "python3 - <<'PY'\nfrom fastapi import FastAPI, Header\nfrom fastapi.testclient import TestClient\nfrom pydantic import BaseModel\n\napp = FastAPI()\n\nclass HeaderModel(BaseModel):\n x_header: str\n\n@app.get(\"/model\")\nasync def read_model(headers: HeaderModel = Header()):\n return {\"headers\": headers}\n\nclient = TestClient(app)\n\n# If we send 'x_header', it's added to params_to_process['x_header'] = 'baz'.\n# We should only add it if it doesn't contain underscores, OR if convert_underscores is False.\n# The loop:\n# for key in received_params.keys():\n# if key not in processed_keys:\n# ...\n# params_to_process[key] = value\n#\n# If we change it to:\n# for key in received_params.keys():\n# if key not in processed_keys:\n# if \"_\" in key and default_convert_underscores:\n# continue\n# ...\n#\n# But default_convert_underscores is only defined if len(fields) == 1 and ...\n# Let's see where it's defined.\nPY\n"
} | {"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0} |
| 40 | run_command | {
"command": "sed -n '797,805p' fastapi/dependencies/utils.py"
} | {"status": "ok", "stdout": " default_convert_underscores = True\n if len(fields) == 1 and lenient_issubclass(\n first_field.field_info.annotation, BaseModel\n )full{"status": "ok", "stdout": " default_convert_underscores = True\n if len(fields) == 1 and lenient_issubclass(\n first_field.field_info.annotation, BaseModel\n ):\n fields_to_extract = get_cached_model_fields(first_field.field_info.annotation)\n single_not_embedded_field = True\n # If headers are in a Pydantic model, the way to disable convert_underscores\n # would be with Header(convert_underscores=False) at the Pydantic model level\n default_convert_underscores = getattr(\n", "stderr": "", "exit_code": 0} |
| 41 | run_command | {
"command": "python3 - <<'PY'\nfrom fastapi import FastAPI, Header\nfrom fastapi.testclient import TestClient\nfrom pydantic import BaseModel\n\napp = FastAPI()\n\nclass HeaderModel(BaseModel):\n x_header: str\n\n@app.get(\"/model\")\nasync def read_model(headers: HeaderModel = Header()):\n return {\"headers\": headers}\n\nclient = TestClient(app)\n\n# If we send 'x_header', it's added to params_to_process['x_header'] = 'baz'.\n# We should only add it if it doesn't contain underscores, OR if convert_underscores is False.\n# The loop:\n# for key in received_params.keys():\n# if key not in processed_keys:\n# ...\n# params_to_process[key] = value\n#\n# If we change it to:\n# for key in received_params.keys():\n# if key not in processed_keys:\n# if isinstance(received_params, Headers) and \"_\" in key and default_convert_underscores:\n# continue\n# ...\n#\n# Let's test this hypothesis.\nPY\n"
} | {"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0} |
| 42 | run_command | {
"command": "cd /workspace && python3 - <<'PY'\nfrom pathlib import Path\np = Path(\"fastapi/dependencies/utils.py\")\ns = p.read_text()\nold = \"\"\" for key in received_params.keys():\n if key not in processed_keys:\"\"\"\nnew = \"\"\" for key in received_params.keys():\n if key not in processed_keys:\n if isinstance(received_params, Headers) and \"_\" in key and default_convert_underscores:\n continue\"\"\"\n# Need to import Headers inside the script or use the same name\n# But the script is just replacing text.\n# Wait, Headers is not defined in the scope of the replacement.\n# But it is used in the code.\n# Let's check if Headers is available in the module.\n# Yes, it is imported as: from starlette.datastructures import Headers as Headers\n# No, it's imported in fastapi/datastructures.py and then maybe used.\n# Let's check imports in fastapi/dependencies/utils.py.\nPY\n"
} | {"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0} |
| 43 | run_command | {
"command": "sed -n '1,100p' fastapi/dependencies/utils.py | grep \"Headers\""
} | {"status": "ok", "stdout": " Headers,\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": " Headers,\n", "stderr": "", "exit_code": 0} |