From f9a4828a84053e69a364db589ee5b176e71abc59 Mon Sep 17 00:00:00 2001 From: Kanchan-Microsoft Date: Fri, 17 Apr 2026 09:56:03 +0530 Subject: [PATCH 1/3] Refactor error handling and clean up unused state variables in various scripts --- scripts/validate_bicep_params.py | 2 ++ src/backend/common/database/cosmosdb.py | 3 +++ src/backend/sql_agents/convert_script.py | 1 - src/frontend/src/pages/modernizationPage.tsx | 10 +++------- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/validate_bicep_params.py b/scripts/validate_bicep_params.py index ec627dae..9c606ed2 100644 --- a/scripts/validate_bicep_params.py +++ b/scripts/validate_bicep_params.py @@ -110,6 +110,8 @@ def parse_parameters_env_vars(json_path: Path) -> dict[str, list[str]]: data = json.loads(sanitized) params = data.get("parameters", {}) except json.JSONDecodeError: + # If JSON parsing fails, params remains empty and no variables will be found. + # This is acceptable as the function will return an empty result dict. pass # Walk each top-level parameter and scan its entire serialized value diff --git a/src/backend/common/database/cosmosdb.py b/src/backend/common/database/cosmosdb.py index 8c56286a..b9fe8fa3 100644 --- a/src/backend/common/database/cosmosdb.py +++ b/src/backend/common/database/cosmosdb.py @@ -109,6 +109,9 @@ async def create_batch(self, user_id: str, batch_id: UUID) -> BatchRecord: self.logger.info("Returning existing batch record", batch_id=str(batch_id)) return BatchRecord.fromdb(batchexists) + + # This line should never be reached as all paths above either return or raise + raise RuntimeError(f"Unexpected state while processing batch {batch_id}") except Exception as e: self.logger.error("Failed to create batch", error=str(e)) diff --git a/src/backend/sql_agents/convert_script.py b/src/backend/sql_agents/convert_script.py index b6cb7ec8..a569d96f 100644 --- a/src/backend/sql_agents/convert_script.py +++ b/src/backend/sql_agents/convert_script.py @@ -271,7 +271,6 @@ async def convert_script( FileResult.ERROR, ), ) - is_complete = True break if comms_manager.group_chat.is_complete: diff --git a/src/frontend/src/pages/modernizationPage.tsx b/src/frontend/src/pages/modernizationPage.tsx index eb22ed07..1157ed65 100644 --- a/src/frontend/src/pages/modernizationPage.tsx +++ b/src/frontend/src/pages/modernizationPage.tsx @@ -478,9 +478,6 @@ const getPrintFileStatus = (status: string): string => { const ModernizationPage = () => { const { batchId } = useParams<{ batchId: string }>(); const navigate = useNavigate(); - - // Redux state to listen for start processing completion - const batchState = useSelector((state: any) => state.batch); const [batchSummary, setBatchSummary] = useState(null); const styles = useStyles(); @@ -497,7 +494,6 @@ const ModernizationPage = () => { const [fileId, setFileId] = React.useState(""); const [expandedSections, setExpandedSections] = React.useState([]); const [allFilesCompleted, setAllFilesCompleted] = useState(false); - const [progressPercentage, setProgressPercentage] = useState(0); const [isZipButtonDisabled, setIsZipButtonDisabled] = useState(true); const [fileLoading, setFileLoading] = useState(false); const [lastActivityTime, setLastActivityTime] = useState(Date.now()); @@ -514,7 +510,7 @@ const ModernizationPage = () => { const selectedFile = files.find((f) => f.id === selectedFileId); if (!selectedFile || !selectedFile.translatedCode) { setFileLoading(true); - const newFileUpdate = await fetchFileFromAPI(selectedFile?.fileId || ""); + await fetchFileFromAPI(selectedFile?.fileId || ""); setFileLoading(false); } else { @@ -970,13 +966,13 @@ useEffect(() => { // Set a timeout for initial loading - if no progress after 30 seconds, show error useEffect(() => { const loadingTimeout = setTimeout(() => { - if (progressPercentage < 5 && showLoading) { + if (showLoading) { setLoadingError('Processing is taking longer than expected. You can continue waiting or try again later.'); } }, 30000); return () => clearTimeout(loadingTimeout); - }, [progressPercentage, showLoading]); + }, [showLoading]); // Poll summary status during inactivity, but do not force completion/navigation by timeout. useEffect(() => { From 82991cf5ca06048124eddfc1a14ccd2eaf493f40 Mon Sep 17 00:00:00 2001 From: Kanchan-Microsoft Date: Fri, 17 Apr 2026 10:12:28 +0530 Subject: [PATCH 2/3] fixed pylint issue --- src/backend/common/database/cosmosdb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/common/database/cosmosdb.py b/src/backend/common/database/cosmosdb.py index b9fe8fa3..7e5e9108 100644 --- a/src/backend/common/database/cosmosdb.py +++ b/src/backend/common/database/cosmosdb.py @@ -109,7 +109,7 @@ async def create_batch(self, user_id: str, batch_id: UUID) -> BatchRecord: self.logger.info("Returning existing batch record", batch_id=str(batch_id)) return BatchRecord.fromdb(batchexists) - + # This line should never be reached as all paths above either return or raise raise RuntimeError(f"Unexpected state while processing batch {batch_id}") From 2029575e842dc8e50b32fa88406d26226a8835e4 Mon Sep 17 00:00:00 2001 From: Kanchan-Microsoft Date: Fri, 17 Apr 2026 10:29:58 +0530 Subject: [PATCH 3/3] remove unused import of useSelector --- src/frontend/src/pages/modernizationPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/frontend/src/pages/modernizationPage.tsx b/src/frontend/src/pages/modernizationPage.tsx index 1157ed65..0ae108e1 100644 --- a/src/frontend/src/pages/modernizationPage.tsx +++ b/src/frontend/src/pages/modernizationPage.tsx @@ -4,7 +4,6 @@ import Header from "../components/Header/Header"; import HeaderTools from "../components/Header/HeaderTools"; import PanelLeft from "../components/Panels/PanelLeft"; import webSocketService from "../api/WebSocketService"; -import { useSelector } from 'react-redux'; import { Button, Text,