#33948: 'Response' object has no attribute 'headers'
-------------------------------------------+------------------------
               Reporter:  Sarankrishna     |          Owner:  nobody
                   Type:  Bug              |         Status:  new
              Component:  Core (Other)     |        Version:  4.0
               Severity:  Release blocker  |       Keywords:
           Triage Stage:  Unreviewed       |      Has patch:  0
    Needs documentation:  0                |    Needs tests:  0
Patch needs improvement:  0                |  Easy pickings:  0
                  UI/UX:  0                |
-------------------------------------------+------------------------
 I am getting error while calling REST API endpoint. It looks like this is
 caused by the middleware
 "django.middleware.clickjacking.XFrameOptionsMiddleware". we have
 configured clickjacking middleware in django project like below. We were
 not getting this error while using Django 2.0.4. But now we have upgraded
 django version to 4.0.6. After the upgrade, we started getting this error
 while calling REST API endpoint.  Unable to understand why Response object
 won't have header attribute.  Refer below exception log

 MIDDLEWARE = [
     ...
     'django.middleware.clickjacking.XFrameOptionsMiddleware',
     ...
 ]

 Exception Log
 ===========

 {"asctime": "2022-08-21 10:20:45,228", "created": 1661077245.2283375,
 "filename": "log.py", "funcName": "log_response", "levelname": "ERROR",
 "levelno": 40, "lineno": 241, "module": "log", "msecs":
 228.33752632141113, "message": "Internal Server Error:
 /v1/zone/schemas/123-38b4-5591-8cfa-1234/", "name": "django.request",
 "pathname": "/usr/local/lib/python3.10/site-packages/django/utils/log.py",
 "process": 10, "processName": "MainProcess", "relativeCreated":
 285498.6550807953, "thread": 140675831812672, "threadName": "Dummy-33",
 "exc_info": "Traceback (most recent call last):\n  File
 \"/usr/local/lib/python3.10/site-
 packages/django/core/handlers/exception.py\", line 55, in inner\n
 response = get_response(request)\n  File \"/usr/local/lib/python3.10/site-
 packages/django/utils/deprecation.py\", line 136, in __call__\n
 response = self.process_response(request, response)\n  File
 \"/usr/local/lib/python3.10/site-
 packages/django/middleware/clickjacking.py\", line 27, in
 process_response\n    if response.get(\"X-Frame-Options\") is not None:\n
 File \"/usr/local/lib/python3.10/site-packages/django/http/response.py\",
 line 198, in get\n    return self.headers.get(header,
 alternate)\nAttributeError: 'Response' object has no attribute 'headers'",
 "status_code": 500, "request": "<WSGIRequest: GET
 '/v1/zone/schemas/123-38b4-5591-8cfa-1234/'>"}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33948>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070182c9eea874-fb441bd7-2705-43ef-a6b2-c599fcb21ced-000000%40eu-central-1.amazonses.com.

Reply via email to