From 1fe59810956a28b53af3e0a8a515c09f0317ab84 Mon Sep 17 00:00:00 2001 From: Alexander Borg Date: Tue, 23 Sep 2025 10:23:07 +0200 Subject: [PATCH] Fix jwt-token --- client/src/components/AlertModals.jsx | 9 +++++ client/src/components/ErrorBoundary.jsx | 49 +++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 client/src/components/ErrorBoundary.jsx diff --git a/client/src/components/AlertModals.jsx b/client/src/components/AlertModals.jsx index 4f77e92..ad95d4e 100644 --- a/client/src/components/AlertModals.jsx +++ b/client/src/components/AlertModals.jsx @@ -43,6 +43,15 @@ export const EditAlertModal = ({ rule, onClose, onSuccess }) => { if (rule) { // Normalize alert_channels - ensure it's always an array let alertChannels = rule.alert_channels || ['sms']; + + // DEBUG: Check for problematic alert_channels objects + if (typeof alertChannels === 'object' && alertChannels !== null) { + const hasKeys = Object.keys(alertChannels).some(key => ['sms', 'webhook', 'email'].includes(key)); + if (hasKeys) { + console.log('DEBUG AlertModals: Found problematic alert_channels object:', alertChannels, 'for rule:', rule.id); + } + } + if (typeof alertChannels === 'object' && !Array.isArray(alertChannels)) { // Convert object like {sms: true, webhook: false, email: true} to array alertChannels = Object.keys(alertChannels).filter(key => alertChannels[key]); diff --git a/client/src/components/ErrorBoundary.jsx b/client/src/components/ErrorBoundary.jsx new file mode 100644 index 0000000..71460aa --- /dev/null +++ b/client/src/components/ErrorBoundary.jsx @@ -0,0 +1,49 @@ +import React from 'react'; + +class ErrorBoundary extends React.Component { + constructor(props) { + super(props); + this.state = { hasError: false, error: null, errorInfo: null }; + } + + static getDerivedStateFromError(error) { + return { hasError: true }; + } + + componentDidCatch(error, errorInfo) { + console.error('ERROR BOUNDARY CAUGHT:', error); + console.error('ERROR BOUNDARY STACK:', errorInfo); + + // Check if this is the specific object rendering error + if (error.message && error.message.includes('Objects are not valid as a React child')) { + console.error('🚨 FOUND THE OBJECT RENDERING ERROR!'); + console.error('Error message:', error.message); + console.error('Stack trace:', error.stack); + console.error('Component stack:', errorInfo.componentStack); + } + + this.setState({ + error: error, + errorInfo: errorInfo + }); + } + + render() { + if (this.state.hasError) { + return ( +
+

Something went wrong.

+
+ {this.state.error && this.state.error.toString()} +
+ {this.state.errorInfo.componentStack} +
+
+ ); + } + + return this.props.children; + } +} + +export default ErrorBoundary; \ No newline at end of file