This is an automated email from the ASF dual-hosted git repository.

yasithdev pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airavata-portals.git


The following commit(s) were added to refs/heads/main by this push:
     new d4ed13208 fix(auth): return a clean response when settings_local 
download is blocked in DEBUG (#223)
d4ed13208 is described below

commit d4ed13208e8940948aba6b2a5c95af4166e959c0
Author: Yasith Jayawardana <[email protected]>
AuthorDate: Sun Jun 14 00:04:56 2026 -0400

    fix(auth): return a clean response when settings_local download is blocked 
in DEBUG (#223)
    
    download_settings_local raised a bare Exception in DEBUG mode, which Django
    renders as an unhandled 500 + stack trace. Return HttpResponseBadRequest 
with the
    same message so the intentional restriction degrades to a graceful 400.
---
 airavata-django-portal/django_airavata/apps/auth/views.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/airavata-django-portal/django_airavata/apps/auth/views.py 
b/airavata-django-portal/django_airavata/apps/auth/views.py
index 376da57ae..ee99f7eb5 100644
--- a/airavata-django-portal/django_airavata/apps/auth/views.py
+++ b/airavata-django-portal/django_airavata/apps/auth/views.py
@@ -7,7 +7,12 @@ import requests
 from django.conf import settings
 from django.contrib import messages
 from django.core.exceptions import PermissionDenied
-from django.http import FileResponse, HttpResponseForbidden, JsonResponse
+from django.http import (
+    FileResponse,
+    HttpResponseBadRequest,
+    HttpResponseForbidden,
+    JsonResponse,
+)
 from django.shortcuts import redirect, render
 from django.template.loader import render_to_string
 from django.urls import reverse
@@ -236,7 +241,7 @@ def download_settings_local(request):
         raise PermissionDenied()
 
     if settings.DEBUG:
-        raise Exception(
+        return HttpResponseBadRequest(
             "Downloading a settings_local.py file isn't allowed in DEBUG mode."
         )
 

Reply via email to