request = <WSGIRequest: GET '/api/1/graph/stats/'>
@wraps(get_response)
def inner(request):
try:
> response = get_response(request)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:34:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.middleware.common.CommonMiddleware object at 0x7facfc41aeb8>
request = <WSGIRequest: GET '/api/1/graph/stats/'>
def __call__(self, request):
response = None
if hasattr(self, 'process_request'):
> response = self.process_request(request)
.tox/py3/lib/python3.7/site-packages/django/utils/deprecation.py:93:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.middleware.common.CommonMiddleware object at 0x7facfc41aeb8>
request = <WSGIRequest: GET '/api/1/graph/stats/'>
def process_request(self, request):
"""
Check for denied User-Agents and rewrite the URL based on
settings.APPEND_SLASH and settings.PREPEND_WWW
"""
# Check for denied User-Agents
if 'HTTP_USER_AGENT' in request.META:
for user_agent_regex in settings.DISALLOWED_USER_AGENTS:
if user_agent_regex.search(request.META['HTTP_USER_AGENT']):
raise PermissionDenied('Forbidden user agent')
# Check for a redirect based on settings.PREPEND_WWW
> host = request.get_host()
.tox/py3/lib/python3.7/site-packages/django/middleware/common.py:47:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WSGIRequest: GET '/api/1/graph/stats/'>
def get_host(self):
"""Return the HTTP host using the environment or request headers."""
host = self._get_raw_host()
# Allow variants of localhost if ALLOWED_HOSTS is empty and DEBUG=True.
allowed_hosts = settings.ALLOWED_HOSTS
if settings.DEBUG and not allowed_hosts:
allowed_hosts = ['localhost', '127.0.0.1', '[::1]']
domain, port = split_domain_port(host)
if domain and validate_host(domain, allowed_hosts):
return host
else:
msg = "Invalid HTTP_HOST header: %r." % host
if domain:
msg += " You may need to add %r to ALLOWED_HOSTS." % domain
else:
msg += " The domain name provided is not valid according to RFC 1034/1035."
> raise DisallowedHost(msg)
E django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: 'archive.internal.softwareheritage.org'. You may need to add 'archive.internal.softwareheritage.org' to ALLOWED_HOSTS.
.tox/py3/lib/python3.7/site-packages/django/http/request.py:111: DisallowedHost
During handling of the above exception, another exception occurred:
request = <WSGIRequest: GET '/api/1/graph/stats/'>
@wraps(get_response)
def inner(request):
try:
> response = get_response(request)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:34:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <corsheaders.middleware.CorsMiddleware object at 0x7facfc41af98>
request = <WSGIRequest: GET '/api/1/graph/stats/'>
def __call__(self, request):
response = None
if hasattr(self, 'process_request'):
response = self.process_request(request)
> response = response or self.get_response(request)
.tox/py3/lib/python3.7/site-packages/django/utils/deprecation.py:94:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/api/1/graph/stats/'>
@wraps(get_response)
def inner(request):
try:
response = get_response(request)
except Exception as exc:
> response = response_for_exception(request, exc)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:36:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/api/1/graph/stats/'>
exc = DisallowedHost("Invalid HTTP_HOST header: 'archive.internal.softwareheritage.org'. You may need to add 'archive.internal.softwareheritage.org' to ALLOWED_HOSTS.")
def response_for_exception(request, exc):
if isinstance(exc, Http404):
if settings.DEBUG:
response = debug.technical_404_response(request, exc)
else:
response = get_exception_response(request, get_resolver(get_urlconf()), 404, exc)
elif isinstance(exc, PermissionDenied):
response = get_exception_response(request, get_resolver(get_urlconf()), 403, exc)
log_response(
'Forbidden (Permission denied): %s', request.path,
response=response,
request=request,
exc_info=sys.exc_info(),
)
elif isinstance(exc, MultiPartParserError):
response = get_exception_response(request, get_resolver(get_urlconf()), 400, exc)
log_response(
'Bad request (Unable to parse request body): %s', request.path,
response=response,
request=request,
exc_info=sys.exc_info(),
)
elif isinstance(exc, SuspiciousOperation):
if isinstance(exc, (RequestDataTooBig, TooManyFieldsSent)):
# POST data can't be accessed again, otherwise the original
# exception would be raised.
request._mark_post_parse_error()
# The request logger receives events for any problematic request
# The security logger receives events for all SuspiciousOperations
security_logger = logging.getLogger('django.security.%s' % exc.__class__.__name__)
security_logger.error(
str(exc),
extra={'status_code': 400, 'request': request},
)
if settings.DEBUG:
response = debug.technical_500_response(request, *sys.exc_info(), status_code=400)
else:
> response = get_exception_response(request, get_resolver(get_urlconf()), 400, exc)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:82:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/api/1/graph/stats/'>
resolver = <URLResolver 'swh.web.urls' (None:None) '^/'>, status_code = 400
exception = DisallowedHost("Invalid HTTP_HOST header: 'archive.internal.softwareheritage.org'. You may need to add 'archive.internal.softwareheritage.org' to ALLOWED_HOSTS.")
def get_exception_response(request, resolver, status_code, exception):
try:
callback, param_dict = resolver.resolve_error_handler(status_code)
response = callback(request, **{**param_dict, 'exception': exception})
except Exception:
signals.got_request_exception.send(sender=None, request=request)
> response = handle_uncaught_exception(request, resolver, sys.exc_info())
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:111:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/api/1/graph/stats/'>
resolver = <URLResolver 'swh.web.urls' (None:None) '^/'>, status_code = 400
exception = DisallowedHost("Invalid HTTP_HOST header: 'archive.internal.softwareheritage.org'. You may need to add 'archive.internal.softwareheritage.org' to ALLOWED_HOSTS.")
def get_exception_response(request, resolver, status_code, exception):
try:
callback, param_dict = resolver.resolve_error_handler(status_code)
> response = callback(request, **{**param_dict, 'exception': exception})
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:108:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/api/1/graph/stats/'>
exception = DisallowedHost("Invalid HTTP_HOST header: 'archive.internal.softwareheritage.org'. You may need to add 'archive.internal.softwareheritage.org' to ALLOWED_HOSTS.")
def swh_handle400(request, exception=None):
"""
Custom Django HTTP error 400 handler for swh-web.
"""
error_description = (
"The server cannot process the request to %s due to "
"something that is perceived to be a client error."
% escape(request.META["PATH_INFO"])
)
> return _generate_error_page(request, 400, error_description)
.tox/py3/lib/python3.7/site-packages/swh/web/common/exc.py:94:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/api/1/graph/stats/'>, error_code = 400
error_description = 'The server cannot process the request to /api/1/graph/stats/ due to something that is perceived to be a client error.'
def _generate_error_page(request, error_code, error_description):
return render(
request,
"error.html",
{
"error_code": error_code,
"error_message": http_status_code_message[error_code],
"error_description": mark_safe(error_description),
},
> status=error_code,
)
.tox/py3/lib/python3.7/site-packages/swh/web/common/exc.py:81:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/api/1/graph/stats/'>, template_name = 'error.html'
context = {'error_code': 400, 'error_description': 'The server cannot process the request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'error_message': 'Bad Request'}
content_type = None, status = 400, using = None
def render(request, template_name, context=None, content_type=None, status=None, using=None):
"""
Return a HttpResponse whose content is filled with the result of calling
django.template.loader.render_to_string() with the passed arguments.
"""
> content = loader.render_to_string(template_name, context, request, using=using)
.tox/py3/lib/python3.7/site-packages/django/shortcuts.py:36:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
template_name = 'error.html'
context = {'error_code': 400, 'error_description': 'The server cannot process the request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'error_message': 'Bad Request'}
request = <WSGIRequest: GET '/api/1/graph/stats/'>, using = None
def render_to_string(template_name, context=None, request=None, using=None):
"""
Load a template and render it with a context. Return a string.
template_name may be a string or a list of strings.
"""
if isinstance(template_name, (list, tuple)):
template = select_template(template_name, using=using)
else:
template = get_template(template_name, using=using)
> return template.render(context, request)
.tox/py3/lib/python3.7/site-packages/django/template/loader.py:62:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.template.backends.django.Template object at 0x7facfc41af60>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
request = <WSGIRequest: GET '/api/1/graph/stats/'>
def render(self, context=None, request=None):
context = make_context(context, request, autoescape=self.backend.engine.autoescape)
try:
> return self.template.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/backends/django.py:61:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.template.base.Template object at 0x7facfc4edc18>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
"Display stage -- can be called many times"
with context.render_context.push_state(self):
if context.template is None:
with context.bind_template(self):
context.template_name = self.name
> return self._render(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:171:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.template.base.Template object at 0x7facfc4edc18>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def instrumented_test_render(self, context):
"""
An instrumented Template render method, providing a signal that can be
intercepted by the test Client.
"""
template_rendered.send(sender=self, template=self, context=context)
> return self.nodelist.render(context)
.tox/py3/lib/python3.7/site-packages/django/test/utils.py:96:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = [<ExtendsNode: extends "layout.html">]
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
bits = []
for node in self:
if isinstance(node, Node):
> bit = node.render_annotated(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:937:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <ExtendsNode: extends "layout.html">
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render_annotated(self, context):
"""
Render the node. If debug is True and an exception occurs during
rendering, the exception is annotated with contextual line information
where it occurred in the template. For internal usage this method is
preferred over using the render method directly.
"""
try:
> return self.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:904:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <ExtendsNode: extends "layout.html">
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
compiled_parent = self.get_parent(context)
if BLOCK_CONTEXT_KEY not in context.render_context:
context.render_context[BLOCK_CONTEXT_KEY] = BlockContext()
block_context = context.render_context[BLOCK_CONTEXT_KEY]
# Add the block nodes from this node to the block context
block_context.add_blocks(self.blocks)
# If this block's parent doesn't have an extends node it is the root,
# and its block nodes also need to be added to the block context.
for node in compiled_parent.nodelist:
# The ExtendsNode has to be the first non-text node.
if not isinstance(node, TextNode):
if not isinstance(node, ExtendsNode):
blocks = {n.name: n for n in
compiled_parent.nodelist.get_nodes_by_type(BlockNode)}
block_context.add_blocks(blocks)
break
# Call Template._render explicitly so the parser context stays
# the same.
with context.render_context.push_state(compiled_parent, isolated_context=False):
> return compiled_parent._render(context)
.tox/py3/lib/python3.7/site-packages/django/template/loader_tags.py:150:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.template.base.Template object at 0x7facfde92978>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def instrumented_test_render(self, context):
"""
An instrumented Template render method, providing a signal that can be
intercepted by the test Client.
"""
template_rendered.send(sender=self, template=self, context=context)
> return self.nodelist.render(context)
.tox/py3/lib/python3.7/site-packages/django/test/utils.py:96:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = [<django.template.defaulttags.CommentNode object at 0x7facfde92a58>, <TextNode: '\n\n<!DOCTYPE html>\n\n'>, <django.te... </div'>, <django.templatetags.static.StaticNode object at 0x7facfde9eb00>, <TextNode: '" /></a>\n </div>\n <'>]
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
bits = []
for node in self:
if isinstance(node, Node):
> bit = node.render_annotated(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:937:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <IfNode>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render_annotated(self, context):
"""
Render the node. If debug is True and an exception occurs during
rendering, the exception is annotated with contextual line information
where it occurred in the template. For internal usage this method is
preferred over using the render method directly.
"""
try:
> return self.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:904:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <IfNode>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
for condition, nodelist in self.conditions_nodelists:
if condition is not None: # if / elif clause
try:
match = condition.eval(context)
except VariableDoesNotExist:
match = None
else: # else clause
match = True
if match:
> return nodelist.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/defaulttags.py:309:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = [<TextNode: '\n '>, <IfNode>, <TextNode: '\n '>]
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
bits = []
for node in self:
if isinstance(node, Node):
> bit = node.render_annotated(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:937:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <IfNode>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render_annotated(self, context):
"""
Render the node. If debug is True and an exception occurs during
rendering, the exception is annotated with contextual line information
where it occurred in the template. For internal usage this method is
preferred over using the render method directly.
"""
try:
> return self.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:904:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <IfNode>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
for condition, nodelist in self.conditions_nodelists:
if condition is not None: # if / elif clause
try:
match = condition.eval(context)
except VariableDoesNotExist:
match = None
else: # else clause
match = True
if match:
> return nodelist.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/defaulttags.py:309:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = [<TextNode: '\n <a href='>, <django.template.defaulttags.URLNode object at 0x7facfde9dba8>, <TextNode: '?next_path='>, <Variable Node: request.build_absolute_uri>, <TextNode: '">login</a>\n '>]
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
bits = []
for node in self:
if isinstance(node, Node):
> bit = node.render_annotated(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:937:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Variable Node: request.build_absolute_uri>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render_annotated(self, context):
"""
Render the node. If debug is True and an exception occurs during
rendering, the exception is annotated with contextual line information
where it occurred in the template. For internal usage this method is
preferred over using the render method directly.
"""
try:
> return self.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:904:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Variable Node: request.build_absolute_uri>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
try:
> output = self.filter_expression.resolve(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:987:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.template.base.FilterExpression object at 0x7facfde9dc18>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
ignore_failures = False
def resolve(self, context, ignore_failures=False):
if isinstance(self.var, Variable):
try:
> obj = self.var.resolve(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:671:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Variable: 'request.build_absolute_uri'>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def resolve(self, context):
"""Resolve this variable against a given context."""
if self.lookups is not None:
# We're dealing with a variable that needs to be resolved
> value = self._resolve_lookup(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:796:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Variable: 'request.build_absolute_uri'>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def _resolve_lookup(self, context):
"""
Perform resolution of a real variable (i.e. not a literal) against the
given context.
As indicated by the method's name, this method is an implementation
detail and shouldn't be called by external code. Use Variable.resolve()
instead.
"""
current = context
try: # catch-all for silent variable failures
for bit in self.lookups:
try: # dictionary lookup
current = current[bit]
# ValueError/IndexError are for numpy.array lookup on
# numpy < 1.9 and 1.9+ respectively
except (TypeError, AttributeError, KeyError, ValueError, IndexError):
try: # attribute lookup
# Don't return class attributes if the class is the context:
if isinstance(current, BaseContext) and getattr(type(current), bit):
raise AttributeError
current = getattr(current, bit)
except (TypeError, AttributeError):
# Reraise if the exception was raised by a @property
if not isinstance(current, BaseContext) and bit in dir(current):
raise
try: # list-index lookup
current = current[int(bit)]
except (IndexError, # list index out of range
ValueError, # invalid literal for int()
KeyError, # current is a dict without `int(bit)` key
TypeError): # unsubscriptable object
raise VariableDoesNotExist("Failed lookup for key "
"[%s] in %r",
(bit, current)) # missing attribute
if callable(current):
if getattr(current, 'do_not_call_in_templates', False):
pass
elif getattr(current, 'alters_data', False):
current = context.template.engine.string_if_invalid
else:
try: # method call (assuming no args required)
> current = current()
.tox/py3/lib/python3.7/site-packages/django/template/base.py:858:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WSGIRequest: GET '/api/1/graph/stats/'>
location = '/api/1/graph/stats/'
def build_absolute_uri(self, location=None):
"""
Build an absolute URI from the location and the variables available in
this request. If no ``location`` is specified, build the absolute URI
using request.get_full_path(). If the location is absolute, convert it
to an RFC 3987 compliant URI and return it. If location is relative or
is scheme-relative (i.e., ``//example.com/``), urljoin() it to a base
URL constructed from the request variables.
"""
if location is None:
# Make it an absolute url (but schemeless and domainless) for the
# edge case that the path starts with '//'.
location = '//%s' % self.get_full_path()
bits = urlsplit(location)
if not (bits.scheme and bits.netloc):
# Handle the simple, most common case. If the location is absolute
# and a scheme or host (netloc) isn't provided, skip an expensive
# urljoin() as long as no path segments are '.' or '..'.
if (bits.path.startswith('/') and not bits.scheme and not bits.netloc and
'/./' not in bits.path and '/../' not in bits.path):
# If location starts with '//' but has no netloc, reuse the
# schema and netloc from the current request. Strip the double
# slashes and continue as if it wasn't specified.
if location.startswith('//'):
location = location[2:]
> location = self._current_scheme_host + location
.tox/py3/lib/python3.7/site-packages/django/http/request.py:195:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.utils.functional.cached_property object at 0x7fad06361710>
instance = <WSGIRequest: GET '/api/1/graph/stats/'>
cls = <class 'django.core.handlers.wsgi.WSGIRequest'>
def __get__(self, instance, cls=None):
"""
Call the function and put the return value in instance.__dict__ so that
subsequent attribute access on the instance returns the cached value
instead of calling cached_property.__get__().
"""
if instance is None:
return self
> res = instance.__dict__[self.name] = self.func(instance)
.tox/py3/lib/python3.7/site-packages/django/utils/functional.py:80:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WSGIRequest: GET '/api/1/graph/stats/'>
@cached_property
def _current_scheme_host(self):
> return '{}://{}'.format(self.scheme, self.get_host())
.tox/py3/lib/python3.7/site-packages/django/http/request.py:205:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WSGIRequest: GET '/api/1/graph/stats/'>
def get_host(self):
"""Return the HTTP host using the environment or request headers."""
host = self._get_raw_host()
# Allow variants of localhost if ALLOWED_HOSTS is empty and DEBUG=True.
allowed_hosts = settings.ALLOWED_HOSTS
if settings.DEBUG and not allowed_hosts:
allowed_hosts = ['localhost', '127.0.0.1', '[::1]']
domain, port = split_domain_port(host)
if domain and validate_host(domain, allowed_hosts):
return host
else:
msg = "Invalid HTTP_HOST header: %r." % host
if domain:
msg += " You may need to add %r to ALLOWED_HOSTS." % domain
else:
msg += " The domain name provided is not valid according to RFC 1034/1035."
> raise DisallowedHost(msg)
E django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: 'archive.internal.softwareheritage.org'. You may need to add 'archive.internal.softwareheritage.org' to ALLOWED_HOSTS.
.tox/py3/lib/python3.7/site-packages/django/http/request.py:111: DisallowedHost
During handling of the above exception, another exception occurred:
request = <WSGIRequest: GET '/api/1/graph/stats/'>
@wraps(get_response)
def inner(request):
try:
> response = get_response(request)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:34:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.contrib.sessions.middleware.SessionMiddleware object at 0x7facfc41ae80>
request = <WSGIRequest: GET '/api/1/graph/stats/'>
def __call__(self, request):
response = None
if hasattr(self, 'process_request'):
response = self.process_request(request)
> response = response or self.get_response(request)
.tox/py3/lib/python3.7/site-packages/django/utils/deprecation.py:94:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/api/1/graph/stats/'>
@wraps(get_response)
def inner(request):
try:
response = get_response(request)
except Exception as exc:
> response = response_for_exception(request, exc)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:36:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/api/1/graph/stats/'>
exc = DisallowedHost("Invalid HTTP_HOST header: 'archive.internal.softwareheritage.org'. You may need to add 'archive.internal.softwareheritage.org' to ALLOWED_HOSTS.")
def response_for_exception(request, exc):
if isinstance(exc, Http404):
if settings.DEBUG:
response = debug.technical_404_response(request, exc)
else:
response = get_exception_response(request, get_resolver(get_urlconf()), 404, exc)
elif isinstance(exc, PermissionDenied):
response = get_exception_response(request, get_resolver(get_urlconf()), 403, exc)
log_response(
'Forbidden (Permission denied): %s', request.path,
response=response,
request=request,
exc_info=sys.exc_info(),
)
elif isinstance(exc, MultiPartParserError):
response = get_exception_response(request, get_resolver(get_urlconf()), 400, exc)
log_response(
'Bad request (Unable to parse request body): %s', request.path,
response=response,
request=request,
exc_info=sys.exc_info(),
)
elif isinstance(exc, SuspiciousOperation):
if isinstance(exc, (RequestDataTooBig, TooManyFieldsSent)):
# POST data can't be accessed again, otherwise the original
# exception would be raised.
request._mark_post_parse_error()
# The request logger receives events for any problematic request
# The security logger receives events for all SuspiciousOperations
security_logger = logging.getLogger('django.security.%s' % exc.__class__.__name__)
security_logger.error(
str(exc),
extra={'status_code': 400, 'request': request},
)
if settings.DEBUG:
response = debug.technical_500_response(request, *sys.exc_info(), status_code=400)
else:
> response = get_exception_response(request, get_resolver(get_urlconf()), 400, exc)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:82:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/api/1/graph/stats/'>
resolver = <URLResolver 'swh.web.urls' (None:None) '^/'>, status_code = 400
exception = DisallowedHost("Invalid HTTP_HOST header: 'archive.internal.softwareheritage.org'. You may need to add 'archive.internal.softwareheritage.org' to ALLOWED_HOSTS.")
def get_exception_response(request, resolver, status_code, exception):
try:
callback, param_dict = resolver.resolve_error_handler(status_code)
response = callback(request, **{**param_dict, 'exception': exception})
except Exception:
signals.got_request_exception.send(sender=None, request=request)
> response = handle_uncaught_exception(request, resolver, sys.exc_info())
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:111:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/api/1/graph/stats/'>
resolver = <URLResolver 'swh.web.urls' (None:None) '^/'>, status_code = 400
exception = DisallowedHost("Invalid HTTP_HOST header: 'archive.internal.softwareheritage.org'. You may need to add 'archive.internal.softwareheritage.org' to ALLOWED_HOSTS.")
def get_exception_response(request, resolver, status_code, exception):
try:
callback, param_dict = resolver.resolve_error_handler(status_code)
> response = callback(request, **{**param_dict, 'exception': exception})
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:108:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/api/1/graph/stats/'>
exception = DisallowedHost("Invalid HTTP_HOST header: 'archive.internal.softwareheritage.org'. You may need to add 'archive.internal.softwareheritage.org' to ALLOWED_HOSTS.")
def swh_handle400(request, exception=None):
"""
Custom Django HTTP error 400 handler for swh-web.
"""
error_description = (
"The server cannot process the request to %s due to "
"something that is perceived to be a client error."
% escape(request.META["PATH_INFO"])
)
> return _generate_error_page(request, 400, error_description)
.tox/py3/lib/python3.7/site-packages/swh/web/common/exc.py:94:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/api/1/graph/stats/'>, error_code = 400
error_description = 'The server cannot process the request to /api/1/graph/stats/ due to something that is perceived to be a client error.'
def _generate_error_page(request, error_code, error_description):
return render(
request,
"error.html",
{
"error_code": error_code,
"error_message": http_status_code_message[error_code],
"error_description": mark_safe(error_description),
},
> status=error_code,
)
.tox/py3/lib/python3.7/site-packages/swh/web/common/exc.py:81:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/api/1/graph/stats/'>, template_name = 'error.html'
context = {'error_code': 400, 'error_description': 'The server cannot process the request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'error_message': 'Bad Request'}
content_type = None, status = 400, using = None
def render(request, template_name, context=None, content_type=None, status=None, using=None):
"""
Return a HttpResponse whose content is filled with the result of calling
django.template.loader.render_to_string() with the passed arguments.
"""
> content = loader.render_to_string(template_name, context, request, using=using)
.tox/py3/lib/python3.7/site-packages/django/shortcuts.py:36:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
template_name = 'error.html'
context = {'error_code': 400, 'error_description': 'The server cannot process the request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'error_message': 'Bad Request'}
request = <WSGIRequest: GET '/api/1/graph/stats/'>, using = None
def render_to_string(template_name, context=None, request=None, using=None):
"""
Load a template and render it with a context. Return a string.
template_name may be a string or a list of strings.
"""
if isinstance(template_name, (list, tuple)):
template = select_template(template_name, using=using)
else:
template = get_template(template_name, using=using)
> return template.render(context, request)
.tox/py3/lib/python3.7/site-packages/django/template/loader.py:62:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.template.backends.django.Template object at 0x7facfc41a9e8>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
request = <WSGIRequest: GET '/api/1/graph/stats/'>
def render(self, context=None, request=None):
context = make_context(context, request, autoescape=self.backend.engine.autoescape)
try:
> return self.template.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/backends/django.py:61:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.template.base.Template object at 0x7facfc4edc18>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
"Display stage -- can be called many times"
with context.render_context.push_state(self):
if context.template is None:
with context.bind_template(self):
context.template_name = self.name
> return self._render(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:171:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.template.base.Template object at 0x7facfc4edc18>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def instrumented_test_render(self, context):
"""
An instrumented Template render method, providing a signal that can be
intercepted by the test Client.
"""
template_rendered.send(sender=self, template=self, context=context)
> return self.nodelist.render(context)
.tox/py3/lib/python3.7/site-packages/django/test/utils.py:96:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = [<ExtendsNode: extends "layout.html">]
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
bits = []
for node in self:
if isinstance(node, Node):
> bit = node.render_annotated(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:937:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <ExtendsNode: extends "layout.html">
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render_annotated(self, context):
"""
Render the node. If debug is True and an exception occurs during
rendering, the exception is annotated with contextual line information
where it occurred in the template. For internal usage this method is
preferred over using the render method directly.
"""
try:
> return self.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:904:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <ExtendsNode: extends "layout.html">
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
compiled_parent = self.get_parent(context)
if BLOCK_CONTEXT_KEY not in context.render_context:
context.render_context[BLOCK_CONTEXT_KEY] = BlockContext()
block_context = context.render_context[BLOCK_CONTEXT_KEY]
# Add the block nodes from this node to the block context
block_context.add_blocks(self.blocks)
# If this block's parent doesn't have an extends node it is the root,
# and its block nodes also need to be added to the block context.
for node in compiled_parent.nodelist:
# The ExtendsNode has to be the first non-text node.
if not isinstance(node, TextNode):
if not isinstance(node, ExtendsNode):
blocks = {n.name: n for n in
compiled_parent.nodelist.get_nodes_by_type(BlockNode)}
block_context.add_blocks(blocks)
break
# Call Template._render explicitly so the parser context stays
# the same.
with context.render_context.push_state(compiled_parent, isolated_context=False):
> return compiled_parent._render(context)
.tox/py3/lib/python3.7/site-packages/django/template/loader_tags.py:150:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.template.base.Template object at 0x7facfde92978>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def instrumented_test_render(self, context):
"""
An instrumented Template render method, providing a signal that can be
intercepted by the test Client.
"""
template_rendered.send(sender=self, template=self, context=context)
> return self.nodelist.render(context)
.tox/py3/lib/python3.7/site-packages/django/test/utils.py:96:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = [<django.template.defaulttags.CommentNode object at 0x7facfde92a58>, <TextNode: '\n\n<!DOCTYPE html>\n\n'>, <django.te... </div'>, <django.templatetags.static.StaticNode object at 0x7facfde9eb00>, <TextNode: '" /></a>\n </div>\n <'>]
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
bits = []
for node in self:
if isinstance(node, Node):
> bit = node.render_annotated(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:937:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <IfNode>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render_annotated(self, context):
"""
Render the node. If debug is True and an exception occurs during
rendering, the exception is annotated with contextual line information
where it occurred in the template. For internal usage this method is
preferred over using the render method directly.
"""
try:
> return self.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:904:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <IfNode>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
for condition, nodelist in self.conditions_nodelists:
if condition is not None: # if / elif clause
try:
match = condition.eval(context)
except VariableDoesNotExist:
match = None
else: # else clause
match = True
if match:
> return nodelist.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/defaulttags.py:309:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = [<TextNode: '\n '>, <IfNode>, <TextNode: '\n '>]
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
bits = []
for node in self:
if isinstance(node, Node):
> bit = node.render_annotated(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:937:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <IfNode>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render_annotated(self, context):
"""
Render the node. If debug is True and an exception occurs during
rendering, the exception is annotated with contextual line information
where it occurred in the template. For internal usage this method is
preferred over using the render method directly.
"""
try:
> return self.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:904:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <IfNode>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
for condition, nodelist in self.conditions_nodelists:
if condition is not None: # if / elif clause
try:
match = condition.eval(context)
except VariableDoesNotExist:
match = None
else: # else clause
match = True
if match:
> return nodelist.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/defaulttags.py:309:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = [<TextNode: '\n <a href='>, <django.template.defaulttags.URLNode object at 0x7facfde9dba8>, <TextNode: '?next_path='>, <Variable Node: request.build_absolute_uri>, <TextNode: '">login</a>\n '>]
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
bits = []
for node in self:
if isinstance(node, Node):
> bit = node.render_annotated(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:937:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Variable Node: request.build_absolute_uri>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render_annotated(self, context):
"""
Render the node. If debug is True and an exception occurs during
rendering, the exception is annotated with contextual line information
where it occurred in the template. For internal usage this method is
preferred over using the render method directly.
"""
try:
> return self.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:904:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Variable Node: request.build_absolute_uri>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
try:
> output = self.filter_expression.resolve(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:987:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.template.base.FilterExpression object at 0x7facfde9dc18>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
ignore_failures = False
def resolve(self, context, ignore_failures=False):
if isinstance(self.var, Variable):
try:
> obj = self.var.resolve(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:671:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Variable: 'request.build_absolute_uri'>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def resolve(self, context):
"""Resolve this variable against a given context."""
if self.lookups is not None:
# We're dealing with a variable that needs to be resolved
> value = self._resolve_lookup(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:796:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Variable: 'request.build_absolute_uri'>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def _resolve_lookup(self, context):
"""
Perform resolution of a real variable (i.e. not a literal) against the
given context.
As indicated by the method's name, this method is an implementation
detail and shouldn't be called by external code. Use Variable.resolve()
instead.
"""
current = context
try: # catch-all for silent variable failures
for bit in self.lookups:
try: # dictionary lookup
current = current[bit]
# ValueError/IndexError are for numpy.array lookup on
# numpy < 1.9 and 1.9+ respectively
except (TypeError, AttributeError, KeyError, ValueError, IndexError):
try: # attribute lookup
# Don't return class attributes if the class is the context:
if isinstance(current, BaseContext) and getattr(type(current), bit):
raise AttributeError
current = getattr(current, bit)
except (TypeError, AttributeError):
# Reraise if the exception was raised by a @property
if not isinstance(current, BaseContext) and bit in dir(current):
raise
try: # list-index lookup
current = current[int(bit)]
except (IndexError, # list index out of range
ValueError, # invalid literal for int()
KeyError, # current is a dict without `int(bit)` key
TypeError): # unsubscriptable object
raise VariableDoesNotExist("Failed lookup for key "
"[%s] in %r",
(bit, current)) # missing attribute
if callable(current):
if getattr(current, 'do_not_call_in_templates', False):
pass
elif getattr(current, 'alters_data', False):
current = context.template.engine.string_if_invalid
else:
try: # method call (assuming no args required)
> current = current()
.tox/py3/lib/python3.7/site-packages/django/template/base.py:858:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WSGIRequest: GET '/api/1/graph/stats/'>
location = '/api/1/graph/stats/'
def build_absolute_uri(self, location=None):
"""
Build an absolute URI from the location and the variables available in
this request. If no ``location`` is specified, build the absolute URI
using request.get_full_path(). If the location is absolute, convert it
to an RFC 3987 compliant URI and return it. If location is relative or
is scheme-relative (i.e., ``//example.com/``), urljoin() it to a base
URL constructed from the request variables.
"""
if location is None:
# Make it an absolute url (but schemeless and domainless) for the
# edge case that the path starts with '//'.
location = '//%s' % self.get_full_path()
bits = urlsplit(location)
if not (bits.scheme and bits.netloc):
# Handle the simple, most common case. If the location is absolute
# and a scheme or host (netloc) isn't provided, skip an expensive
# urljoin() as long as no path segments are '.' or '..'.
if (bits.path.startswith('/') and not bits.scheme and not bits.netloc and
'/./' not in bits.path and '/../' not in bits.path):
# If location starts with '//' but has no netloc, reuse the
# schema and netloc from the current request. Strip the double
# slashes and continue as if it wasn't specified.
if location.startswith('//'):
location = location[2:]
> location = self._current_scheme_host + location
.tox/py3/lib/python3.7/site-packages/django/http/request.py:195:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.utils.functional.cached_property object at 0x7fad06361710>
instance = <WSGIRequest: GET '/api/1/graph/stats/'>
cls = <class 'django.core.handlers.wsgi.WSGIRequest'>
def __get__(self, instance, cls=None):
"""
Call the function and put the return value in instance.__dict__ so that
subsequent attribute access on the instance returns the cached value
instead of calling cached_property.__get__().
"""
if instance is None:
return self
> res = instance.__dict__[self.name] = self.func(instance)
.tox/py3/lib/python3.7/site-packages/django/utils/functional.py:80:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WSGIRequest: GET '/api/1/graph/stats/'>
@cached_property
def _current_scheme_host(self):
> return '{}://{}'.format(self.scheme, self.get_host())
.tox/py3/lib/python3.7/site-packages/django/http/request.py:205:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WSGIRequest: GET '/api/1/graph/stats/'>
def get_host(self):
"""Return the HTTP host using the environment or request headers."""
host = self._get_raw_host()
# Allow variants of localhost if ALLOWED_HOSTS is empty and DEBUG=True.
allowed_hosts = settings.ALLOWED_HOSTS
if settings.DEBUG and not allowed_hosts:
allowed_hosts = ['localhost', '127.0.0.1', '[::1]']
domain, port = split_domain_port(host)
if domain and validate_host(domain, allowed_hosts):
return host
else:
msg = "Invalid HTTP_HOST header: %r." % host
if domain:
msg += " You may need to add %r to ALLOWED_HOSTS." % domain
else:
msg += " The domain name provided is not valid according to RFC 1034/1035."
> raise DisallowedHost(msg)
E django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: 'archive.internal.softwareheritage.org'. You may need to add 'archive.internal.softwareheritage.org' to ALLOWED_HOSTS.
.tox/py3/lib/python3.7/site-packages/django/http/request.py:111: DisallowedHost
During handling of the above exception, another exception occurred:
request = <WSGIRequest: GET '/api/1/graph/stats/'>
@wraps(get_response)
def inner(request):
try:
> response = get_response(request)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:34:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.middleware.security.SecurityMiddleware object at 0x7facfc41a358>
request = <WSGIRequest: GET '/api/1/graph/stats/'>
def __call__(self, request):
response = None
if hasattr(self, 'process_request'):
response = self.process_request(request)
> response = response or self.get_response(request)
.tox/py3/lib/python3.7/site-packages/django/utils/deprecation.py:94:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/api/1/graph/stats/'>
@wraps(get_response)
def inner(request):
try:
response = get_response(request)
except Exception as exc:
> response = response_for_exception(request, exc)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:36:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/api/1/graph/stats/'>
exc = DisallowedHost("Invalid HTTP_HOST header: 'archive.internal.softwareheritage.org'. You may need to add 'archive.internal.softwareheritage.org' to ALLOWED_HOSTS.")
def response_for_exception(request, exc):
if isinstance(exc, Http404):
if settings.DEBUG:
response = debug.technical_404_response(request, exc)
else:
response = get_exception_response(request, get_resolver(get_urlconf()), 404, exc)
elif isinstance(exc, PermissionDenied):
response = get_exception_response(request, get_resolver(get_urlconf()), 403, exc)
log_response(
'Forbidden (Permission denied): %s', request.path,
response=response,
request=request,
exc_info=sys.exc_info(),
)
elif isinstance(exc, MultiPartParserError):
response = get_exception_response(request, get_resolver(get_urlconf()), 400, exc)
log_response(
'Bad request (Unable to parse request body): %s', request.path,
response=response,
request=request,
exc_info=sys.exc_info(),
)
elif isinstance(exc, SuspiciousOperation):
if isinstance(exc, (RequestDataTooBig, TooManyFieldsSent)):
# POST data can't be accessed again, otherwise the original
# exception would be raised.
request._mark_post_parse_error()
# The request logger receives events for any problematic request
# The security logger receives events for all SuspiciousOperations
security_logger = logging.getLogger('django.security.%s' % exc.__class__.__name__)
security_logger.error(
str(exc),
extra={'status_code': 400, 'request': request},
)
if settings.DEBUG:
response = debug.technical_500_response(request, *sys.exc_info(), status_code=400)
else:
> response = get_exception_response(request, get_resolver(get_urlconf()), 400, exc)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:82:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/api/1/graph/stats/'>
resolver = <URLResolver 'swh.web.urls' (None:None) '^/'>, status_code = 400
exception = DisallowedHost("Invalid HTTP_HOST header: 'archive.internal.softwareheritage.org'. You may need to add 'archive.internal.softwareheritage.org' to ALLOWED_HOSTS.")
def get_exception_response(request, resolver, status_code, exception):
try:
callback, param_dict = resolver.resolve_error_handler(status_code)
response = callback(request, **{**param_dict, 'exception': exception})
except Exception:
signals.got_request_exception.send(sender=None, request=request)
> response = handle_uncaught_exception(request, resolver, sys.exc_info())
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:111:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/api/1/graph/stats/'>
resolver = <URLResolver 'swh.web.urls' (None:None) '^/'>, status_code = 400
exception = DisallowedHost("Invalid HTTP_HOST header: 'archive.internal.softwareheritage.org'. You may need to add 'archive.internal.softwareheritage.org' to ALLOWED_HOSTS.")
def get_exception_response(request, resolver, status_code, exception):
try:
callback, param_dict = resolver.resolve_error_handler(status_code)
> response = callback(request, **{**param_dict, 'exception': exception})
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:108:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/api/1/graph/stats/'>
exception = DisallowedHost("Invalid HTTP_HOST header: 'archive.internal.softwareheritage.org'. You may need to add 'archive.internal.softwareheritage.org' to ALLOWED_HOSTS.")
def swh_handle400(request, exception=None):
"""
Custom Django HTTP error 400 handler for swh-web.
"""
error_description = (
"The server cannot process the request to %s due to "
"something that is perceived to be a client error."
% escape(request.META["PATH_INFO"])
)
> return _generate_error_page(request, 400, error_description)
.tox/py3/lib/python3.7/site-packages/swh/web/common/exc.py:94:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/api/1/graph/stats/'>, error_code = 400
error_description = 'The server cannot process the request to /api/1/graph/stats/ due to something that is perceived to be a client error.'
def _generate_error_page(request, error_code, error_description):
return render(
request,
"error.html",
{
"error_code": error_code,
"error_message": http_status_code_message[error_code],
"error_description": mark_safe(error_description),
},
> status=error_code,
)
.tox/py3/lib/python3.7/site-packages/swh/web/common/exc.py:81:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/api/1/graph/stats/'>, template_name = 'error.html'
context = {'error_code': 400, 'error_description': 'The server cannot process the request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'error_message': 'Bad Request'}
content_type = None, status = 400, using = None
def render(request, template_name, context=None, content_type=None, status=None, using=None):
"""
Return a HttpResponse whose content is filled with the result of calling
django.template.loader.render_to_string() with the passed arguments.
"""
> content = loader.render_to_string(template_name, context, request, using=using)
.tox/py3/lib/python3.7/site-packages/django/shortcuts.py:36:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
template_name = 'error.html'
context = {'error_code': 400, 'error_description': 'The server cannot process the request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'error_message': 'Bad Request'}
request = <WSGIRequest: GET '/api/1/graph/stats/'>, using = None
def render_to_string(template_name, context=None, request=None, using=None):
"""
Load a template and render it with a context. Return a string.
template_name may be a string or a list of strings.
"""
if isinstance(template_name, (list, tuple)):
template = select_template(template_name, using=using)
else:
template = get_template(template_name, using=using)
> return template.render(context, request)
.tox/py3/lib/python3.7/site-packages/django/template/loader.py:62:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.template.backends.django.Template object at 0x7facfbc5de48>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
request = <WSGIRequest: GET '/api/1/graph/stats/'>
def render(self, context=None, request=None):
context = make_context(context, request, autoescape=self.backend.engine.autoescape)
try:
> return self.template.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/backends/django.py:61:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.template.base.Template object at 0x7facfc4edc18>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
"Display stage -- can be called many times"
with context.render_context.push_state(self):
if context.template is None:
with context.bind_template(self):
context.template_name = self.name
> return self._render(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:171:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.template.base.Template object at 0x7facfc4edc18>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def instrumented_test_render(self, context):
"""
An instrumented Template render method, providing a signal that can be
intercepted by the test Client.
"""
template_rendered.send(sender=self, template=self, context=context)
> return self.nodelist.render(context)
.tox/py3/lib/python3.7/site-packages/django/test/utils.py:96:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = [<ExtendsNode: extends "layout.html">]
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
bits = []
for node in self:
if isinstance(node, Node):
> bit = node.render_annotated(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:937:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <ExtendsNode: extends "layout.html">
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render_annotated(self, context):
"""
Render the node. If debug is True and an exception occurs during
rendering, the exception is annotated with contextual line information
where it occurred in the template. For internal usage this method is
preferred over using the render method directly.
"""
try:
> return self.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:904:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <ExtendsNode: extends "layout.html">
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
compiled_parent = self.get_parent(context)
if BLOCK_CONTEXT_KEY not in context.render_context:
context.render_context[BLOCK_CONTEXT_KEY] = BlockContext()
block_context = context.render_context[BLOCK_CONTEXT_KEY]
# Add the block nodes from this node to the block context
block_context.add_blocks(self.blocks)
# If this block's parent doesn't have an extends node it is the root,
# and its block nodes also need to be added to the block context.
for node in compiled_parent.nodelist:
# The ExtendsNode has to be the first non-text node.
if not isinstance(node, TextNode):
if not isinstance(node, ExtendsNode):
blocks = {n.name: n for n in
compiled_parent.nodelist.get_nodes_by_type(BlockNode)}
block_context.add_blocks(blocks)
break
# Call Template._render explicitly so the parser context stays
# the same.
with context.render_context.push_state(compiled_parent, isolated_context=False):
> return compiled_parent._render(context)
.tox/py3/lib/python3.7/site-packages/django/template/loader_tags.py:150:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.template.base.Template object at 0x7facfde92978>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def instrumented_test_render(self, context):
"""
An instrumented Template render method, providing a signal that can be
intercepted by the test Client.
"""
template_rendered.send(sender=self, template=self, context=context)
> return self.nodelist.render(context)
.tox/py3/lib/python3.7/site-packages/django/test/utils.py:96:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = [<django.template.defaulttags.CommentNode object at 0x7facfde92a58>, <TextNode: '\n\n<!DOCTYPE html>\n\n'>, <django.te... </div'>, <django.templatetags.static.StaticNode object at 0x7facfde9eb00>, <TextNode: '" /></a>\n </div>\n <'>]
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
bits = []
for node in self:
if isinstance(node, Node):
> bit = node.render_annotated(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:937:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <IfNode>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render_annotated(self, context):
"""
Render the node. If debug is True and an exception occurs during
rendering, the exception is annotated with contextual line information
where it occurred in the template. For internal usage this method is
preferred over using the render method directly.
"""
try:
> return self.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:904:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <IfNode>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
for condition, nodelist in self.conditions_nodelists:
if condition is not None: # if / elif clause
try:
match = condition.eval(context)
except VariableDoesNotExist:
match = None
else: # else clause
match = True
if match:
> return nodelist.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/defaulttags.py:309:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = [<TextNode: '\n '>, <IfNode>, <TextNode: '\n '>]
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
bits = []
for node in self:
if isinstance(node, Node):
> bit = node.render_annotated(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:937:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <IfNode>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render_annotated(self, context):
"""
Render the node. If debug is True and an exception occurs during
rendering, the exception is annotated with contextual line information
where it occurred in the template. For internal usage this method is
preferred over using the render method directly.
"""
try:
> return self.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:904:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <IfNode>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
for condition, nodelist in self.conditions_nodelists:
if condition is not None: # if / elif clause
try:
match = condition.eval(context)
except VariableDoesNotExist:
match = None
else: # else clause
match = True
if match:
> return nodelist.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/defaulttags.py:309:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = [<TextNode: '\n <a href='>, <django.template.defaulttags.URLNode object at 0x7facfde9dba8>, <TextNode: '?next_path='>, <Variable Node: request.build_absolute_uri>, <TextNode: '">login</a>\n '>]
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
bits = []
for node in self:
if isinstance(node, Node):
> bit = node.render_annotated(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:937:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Variable Node: request.build_absolute_uri>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render_annotated(self, context):
"""
Render the node. If debug is True and an exception occurs during
rendering, the exception is annotated with contextual line information
where it occurred in the template. For internal usage this method is
preferred over using the render method directly.
"""
try:
> return self.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:904:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Variable Node: request.build_absolute_uri>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def render(self, context):
try:
> output = self.filter_expression.resolve(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:987:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.template.base.FilterExpression object at 0x7facfde9dc18>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
ignore_failures = False
def resolve(self, context, ignore_failures=False):
if isinstance(self.var, Variable):
try:
> obj = self.var.resolve(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:671:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Variable: 'request.build_absolute_uri'>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def resolve(self, context):
"""Resolve this variable against a given context."""
if self.lookups is not None:
# We're dealing with a variable that needs to be resolved
> value = self._resolve_lookup(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:796:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Variable: 'request.build_absolute_uri'>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_desc...he request to /api/1/graph/stats/ due to something that is perceived to be a client error.', 'logout_url': '/logout/'}]
def _resolve_lookup(self, context):
"""
Perform resolution of a real variable (i.e. not a literal) against the
given context.
As indicated by the method's name, this method is an implementation
detail and shouldn't be called by external code. Use Variable.resolve()
instead.
"""
current = context
try: # catch-all for silent variable failures
for bit in self.lookups:
try: # dictionary lookup
current = current[bit]
# ValueError/IndexError are for numpy.array lookup on
# numpy < 1.9 and 1.9+ respectively
except (TypeError, AttributeError, KeyError, ValueError, IndexError):
try: # attribute lookup
# Don't return class attributes if the class is the context:
if isinstance(current, BaseContext) and getattr(type(current), bit):
raise AttributeError
current = getattr(current, bit)
except (TypeError, AttributeError):
# Reraise if the exception was raised by a @property
if not isinstance(current, BaseContext) and bit in dir(current):
raise
try: # list-index lookup
current = current[int(bit)]
except (IndexError, # list index out of range
ValueError, # invalid literal for int()
KeyError, # current is a dict without `int(bit)` key
TypeError): # unsubscriptable object
raise VariableDoesNotExist("Failed lookup for key "
"[%s] in %r",
(bit, current)) # missing attribute
if callable(current):
if getattr(current, 'do_not_call_in_templates', False):
pass
elif getattr(current, 'alters_data', False):
current = context.template.engine.string_if_invalid
else:
try: # method call (assuming no args required)
> current = current()
.tox/py3/lib/python3.7/site-packages/django/template/base.py:858:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WSGIRequest: GET '/api/1/graph/stats/'>
location = '/api/1/graph/stats/'
def build_absolute_uri(self, location=None):
"""
Build an absolute URI from the location and the variables available in
this request. If no ``location`` is specified, build the absolute URI
using request.get_full_path(). If the location is absolute, convert it
to an RFC 3987 compliant URI and return it. If location is relative or
is scheme-relative (i.e., ``//example.com/``), urljoin() it to a base
URL constructed from the request variables.
"""
if location is None:
# Make it an absolute url (but schemeless and domainless) for the
# edge case that the path starts with '//'.
location = '//%s' % self.get_full_path()
bits = urlsplit(location)
if not (bits.scheme and bits.netloc):
# Handle the simple, most common case. If the location is absolute
# and a scheme or host (netloc) isn't provided, skip an expensive
# urljoin() as long as no path segments are '.' or '..'.
if (bits.path.startswith('/') and not bits.scheme and not bits.netloc and
'/./' not in bits.path and '/../' not in bits.path):
# If location starts with '//' but has no netloc, reuse the
# schema and netloc from the current request. Strip the double
# slashes and continue as if it wasn't specified.
if location.startswith('//'):
location = location[2:]
> location = self._current_scheme_host + location
.tox/py3/lib/python3.7/site-packages/django/http/request.py:195:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.utils.functional.cached_property object at 0x7fad06361710>
instance = <WSGIRequest: GET '/api/1/graph/stats/'>
cls = <class 'django.core.handlers.wsgi.WSGIRequest'>
def __get__(self, instance, cls=None):
"""
Call the function and put the return value in instance.__dict__ so that
subsequent attribute access on the instance returns the cached value
instead of calling cached_property.__get__().
"""
if instance is None:
return self
> res = instance.__dict__[self.name] = self.func(instance)
.tox/py3/lib/python3.7/site-packages/django/utils/functional.py:80:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WSGIRequest: GET '/api/1/graph/stats/'>
@cached_property
def _current_scheme_host(self):
> return '{}://{}'.format(self.scheme, self.get_host())
.tox/py3/lib/python3.7/site-packages/django/http/request.py:205:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WSGIRequest: GET '/api/1/graph/stats/'>
def get_host(self):
"""Return the HTTP host using the environment or request headers."""
host = self._get_raw_host()
# Allow variants of localhost if ALLOWED_HOSTS is empty and DEBUG=True.
allowed_hosts = settings.ALLOWED_HOSTS
if settings.DEBUG and not allowed_hosts:
allowed_hosts = ['localhost', '127.0.0.1', '[::1]']
domain, port = split_domain_port(host)
if domain and validate_host(domain, allowed_hosts):
return host
else:
msg = "Invalid HTTP_HOST header: %r." % host
if domain:
msg += " You may need to add %r to ALLOWED_HOSTS." % domain
else:
msg += " The domain name provided is not valid according to RFC 1034/1035."
> raise DisallowedHost(msg)
E django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: 'archive.internal.softwareheritage.org'. You may need to add 'archive.internal.softwareheritage.org' to ALLOWED_HOSTS.
.tox/py3/lib/python3.7/site-packages/django/http/request.py:111: DisallowedHost
During handling of the above exception, another exception occurred:
api_client = <rest_framework.test.APIClient object at 0x7fad03c314e0>
requests_mock = <requests_mock.mocker.Mocker object at 0x7facfbc5d6d8>
def test_graph_endpoint_no_authentication_for_vpn_users(api_client, requests_mock):
graph_query = "stats"
url = reverse("api-1-graph", url_args={"graph_query": graph_query})
requests_mock.get(
get_config()["graph"]["server_url"] + graph_query,
json={},
headers={"Content-Type": "application/json"},
)
check_http_get_response(
> api_client, url, status_code=200, server_name=SWH_WEB_INTERNAL_SERVER_NAME
)
.tox/py3/lib/python3.7/site-packages/swh/web/tests/api/views/test_graph.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/web/tests/utils.py:61: in check_http_get_response
SERVER_NAME=server_name if server_name else "testserver",
.tox/py3/lib/python3.7/site-packages/rest_framework/test.py:288: in get
response = super().get(path, data=data, **extra)
.tox/py3/lib/python3.7/site-packages/rest_framework/test.py:205: in get
return self.generic('GET', path, **r)
.tox/py3/lib/python3.7/site-packages/rest_framework/test.py:234: in generic
method, path, data, content_type, secure, **extra)
.tox/py3/lib/python3.7/site-packages/django/test/client.py:422: in generic
return self.request(**r)
.tox/py3/lib/python3.7/site-packages/rest_framework/test.py:285: in request
return super().request(**kwargs)
.tox/py3/lib/python3.7/site-packages/rest_framework/test.py:237: in request
request = super().request(**kwargs)
.tox/py3/lib/python3.7/site-packages/django/test/client.py:485: in request
response = self.handler(environ)
.tox/py3/lib/python3.7/site-packages/django/test/client.py:140: in __call__
response = self.get_response(request)
.tox/py3/lib/python3.7/site-packages/rest_framework/test.py:257: in get_response
return super().get_response(request)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/base.py:75: in get_response
response = self._middleware_chain(request)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:36: in inner
response = response_for_exception(request, exc)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:82: in response_for_exception
response = get_exception_response(request, get_resolver(get_urlconf()), 400, exc)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:111: in get_exception_response
response = handle_uncaught_exception(request, resolver, sys.exc_info())
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:108: in get_exception_response
response = callback(request, **{**param_dict, 'exception': exception})
.tox/py3/lib/python3.7/site-packages/swh/web/common/exc.py:94: in swh_handle400
return _generate_error_page(request, 400, error_description)
.tox/py3/lib/python3.7/site-packages/swh/web/common/exc.py:81: in _generate_error_page
status=error_code,
.tox/py3/lib/python3.7/site-packages/django/shortcuts.py:36: in render
content = loader.render_to_string(template_name, context, request, using=using)
.tox/py3/lib/python3.7/site-packages/django/template/loader.py:62: in render_to_string
return template.render(context, request)
.tox/py3/lib/python3.7/site-packages/django/template/backends/django.py:61: in render
return self.template.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:171: in render
return self._render(context)
.tox/py3/lib/python3.7/site-packages/django/test/utils.py:96: in instrumented_test_render
return self.nodelist.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:937: in render
bit = node.render_annotated(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:904: in render_annotated
return self.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/loader_tags.py:150: in render
return compiled_parent._render(context)
.tox/py3/lib/python3.7/site-packages/django/test/utils.py:96: in instrumented_test_render
return self.nodelist.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:937: in render
bit = node.render_annotated(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:904: in render_annotated
return self.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/defaulttags.py:309: in render
return nodelist.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:937: in render
bit = node.render_annotated(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:904: in render_annotated
return self.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/defaulttags.py:309: in render
return nodelist.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:937: in render
bit = node.render_annotated(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:904: in render_annotated
return self.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:987: in render
output = self.filter_expression.resolve(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:671: in resolve
obj = self.var.resolve(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:796: in resolve
value = self._resolve_lookup(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:858: in _resolve_lookup
current = current()
.tox/py3/lib/python3.7/site-packages/django/http/request.py:195: in build_absolute_uri
location = self._current_scheme_host + location
.tox/py3/lib/python3.7/site-packages/django/utils/functional.py:80: in __get__
res = instance.__dict__[self.name] = self.func(instance)
.tox/py3/lib/python3.7/site-packages/django/http/request.py:205: in _current_scheme_host
return '{}://{}'.format(self.scheme, self.get_host())
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WSGIRequest: GET '/api/1/graph/stats/'>
def get_host(self):
"""Return the HTTP host using the environment or request headers."""
host = self._get_raw_host()
# Allow variants of localhost if ALLOWED_HOSTS is empty and DEBUG=True.
allowed_hosts = settings.ALLOWED_HOSTS
if settings.DEBUG and not allowed_hosts:
allowed_hosts = ['localhost', '127.0.0.1', '[::1]']
domain, port = split_domain_port(host)
if domain and validate_host(domain, allowed_hosts):
return host
else:
msg = "Invalid HTTP_HOST header: %r." % host
if domain:
msg += " You may need to add %r to ALLOWED_HOSTS." % domain
else:
msg += " The domain name provided is not valid according to RFC 1034/1035."
> raise DisallowedHost(msg)
E django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: 'archive.internal.softwareheritage.org'. You may need to add 'archive.internal.softwareheritage.org' to ALLOWED_HOSTS.
.tox/py3/lib/python3.7/site-packages/django/http/request.py:111: DisallowedHost
TEST RESULT
TEST RESULT
- Run At
- Oct 23 2020, 1:33 PM