From 461eb7ab8543e3de295fee759d892b5c50708f31 Mon Sep 17 00:00:00 2001 From: Chandrapal Badshah <12944530+Chan9390@users.noreply.github.com> Date: Wed, 30 Apr 2025 14:33:05 +0530 Subject: [PATCH] Update Lighthouse show key response --- api/src/backend/api/tests/test_views.py | 2 +- api/src/backend/api/v1/views.py | 7 ++++--- ui/actions/lighthouse/lighthouse.ts | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/api/src/backend/api/tests/test_views.py b/api/src/backend/api/tests/test_views.py index 7e44f3f5db..92d7002761 100644 --- a/api/src/backend/api/tests/test_views.py +++ b/api/src/backend/api/tests/test_views.py @@ -5593,7 +5593,7 @@ class TestLighthouseConfigViewSet: reverse("lighthouseconfig-show-key", kwargs={"pk": config_id}) ) assert response.status_code == status.HTTP_200_OK - assert response.json()["data"]["api_key"] == expected_api_key + assert response.json()["data"]["attributes"]["api_key"] == expected_api_key def test_lighthouse_config_filters( self, authenticated_client, lighthouse_config_fixture diff --git a/api/src/backend/api/v1/views.py b/api/src/backend/api/v1/views.py index 056e90e2b8..f3ea6d10a4 100644 --- a/api/src/backend/api/v1/views.py +++ b/api/src/backend/api/v1/views.py @@ -13,9 +13,7 @@ from config.settings.social_login import ( GITHUB_OAUTH_CALLBACK_URL, GOOGLE_OAUTH_CALLBACK_URL, ) -from cryptography.fernet import Fernet from dj_rest_auth.registration.views import SocialLoginView -from django.conf import settings from django.conf import settings as django_settings from django.contrib.postgres.aggregates import ArrayAgg from django.contrib.postgres.search import SearchQuery @@ -2884,7 +2882,10 @@ class LighthouseConfigViewSet(BaseRLSViewSet): status=status.HTTP_400_BAD_REQUEST, ) return Response( - {"api_key": decrypted_key}, + data={ + "type": "lighthouse-config", + "attributes": {"api_key": decrypted_key}, + }, status=status.HTTP_200_OK, ) except Exception as e: diff --git a/ui/actions/lighthouse/lighthouse.ts b/ui/actions/lighthouse/lighthouse.ts index 34a3dafeb5..00ccaf182f 100644 --- a/ui/actions/lighthouse/lighthouse.ts +++ b/ui/actions/lighthouse/lighthouse.ts @@ -41,7 +41,7 @@ export const getAIKey = async (): Promise => { }); const data = await response.json(); - return data.data.api_key; + return data.data.attributes.api_key; }; export const createLighthouseConfig = async (config: {