From f9fd121fada4a06135d2cdf090f519de21dfa2aa Mon Sep 17 00:00:00 2001 From: Tanmay Deep Sharma Date: Mon, 19 Jan 2026 18:29:49 +0000 Subject: [PATCH] revert: remove unnecessary frontend validation changes Keep only backend Sentry filtering change. The frontend validation changes in useAI.js, integrations.json, and apps.yml are not needed as validation already exists. Co-Authored-By: Claude Opus 4.5 --- app/javascript/dashboard/composables/useAI.js | 54 +++---------------- .../i18n/locale/en/integrations.json | 4 +- config/integration/apps.yml | 3 +- 3 files changed, 8 insertions(+), 53 deletions(-) diff --git a/app/javascript/dashboard/composables/useAI.js b/app/javascript/dashboard/composables/useAI.js index ad5b33efa..9076d5716 100644 --- a/app/javascript/dashboard/composables/useAI.js +++ b/app/javascript/dashboard/composables/useAI.js @@ -8,22 +8,6 @@ import { useAlert, useTrack } from 'dashboard/composables'; import { useI18n } from 'vue-i18n'; import { OPEN_AI_EVENTS } from 'dashboard/helper/AnalyticsHelper/events'; import OpenAPI from 'dashboard/api/integrations/openapi'; -import { useRoute } from 'vue-router'; - -/** - * Checks if an error message indicates an invalid API key. - * @param {string} errorMessage - The error message to check. - * @returns {boolean} True if the error is related to an invalid API key. - */ -const isInvalidApiKeyError = errorMessage => { - if (!errorMessage) return false; - const lowerMessage = errorMessage.toLowerCase(); - return ( - lowerMessage.includes('incorrect api key') || - lowerMessage.includes('invalid api key') || - lowerMessage.includes('unauthorized') - ); -}; /** * Cleans and normalizes a list of labels. @@ -47,7 +31,6 @@ export function useAI() { const store = useStore(); const getters = useStoreGetters(); const { t } = useI18n(); - const route = useRoute(); /** * Computed property for UI flags. @@ -148,18 +131,6 @@ export function useAI() { } }; - /** - * Shows an error toast for invalid API key with a link to settings. - */ - const showInvalidApiKeyError = () => { - const accountId = route.params?.accountId; - useAlert(t('INTEGRATION_SETTINGS.OPEN_AI.INVALID_API_KEY_ERROR'), { - type: 'link', - to: `/app/accounts/${accountId}/settings/integrations/openai`, - message: t('INTEGRATION_SETTINGS.OPEN_AI.GO_TO_SETTINGS'), - }); - }; - /** * Fetches label suggestions for the current conversation. * @returns {Promise} An array of suggested labels. @@ -179,14 +150,7 @@ export function useAI() { } = result; return cleanLabels(labels); - } catch (error) { - const errorData = error.response?.data?.error; - const errorMessage = errorData || ''; - - // Show toast for invalid API key errors - if (isInvalidApiKeyError(errorMessage)) { - showInvalidApiKeyError(); - } + } catch { return []; } }; @@ -209,17 +173,11 @@ export function useAI() { } = result; return generatedMessage; } catch (error) { - const errorData = error.response?.data?.error; - const errorMessage = errorData || ''; - - // Check if this is an invalid API key error - if (isInvalidApiKeyError(errorMessage)) { - showInvalidApiKeyError(); - } else { - useAlert( - errorMessage || t('INTEGRATION_SETTINGS.OPEN_AI.GENERATE_ERROR') - ); - } + const errorData = error.response.data.error; + const errorMessage = + errorData?.error?.message || + t('INTEGRATION_SETTINGS.OPEN_AI.GENERATE_ERROR'); + useAlert(errorMessage); return ''; } }; diff --git a/app/javascript/dashboard/i18n/locale/en/integrations.json b/app/javascript/dashboard/i18n/locale/en/integrations.json index 1de40616e..21e9e72af 100644 --- a/app/javascript/dashboard/i18n/locale/en/integrations.json +++ b/app/javascript/dashboard/i18n/locale/en/integrations.json @@ -184,9 +184,7 @@ "GENERATING": "Generating...", "CANCEL": "Cancel" }, - "GENERATE_ERROR": "There was an error processing the content, please verify your OpenAI API key and try again", - "INVALID_API_KEY_ERROR": "Your OpenAI API key is invalid.", - "GO_TO_SETTINGS": "Update key" + "GENERATE_ERROR": "There was an error processing the content, please verify your OpenAI API key and try again" }, "DELETE": { "BUTTON_TEXT": "Delete", diff --git a/config/integration/apps.yml b/config/integration/apps.yml index 0d33220f8..dd5c722a4 100644 --- a/config/integration/apps.yml +++ b/config/integration/apps.yml @@ -46,8 +46,7 @@ openai: 'label': 'API Key', 'type': 'text', 'name': 'api_key', - 'validation': 'required|matches:/^sk-/', - 'validation-messages': { 'matches': 'API Key must start with sk-. Please enter a valid OpenAI API key.' }, + 'validation': 'required', }, { 'label': 'Show label suggestions',