From b97571051fe0194aff1efb3c0a96317bd85d9170 Mon Sep 17 00:00:00 2001 From: "Prekshith D J (Persistent Systems Inc)" Date: Thu, 9 Apr 2026 18:13:39 +0530 Subject: [PATCH 1/2] Fixed all the code quality issues --- infra/scripts/validate_bicep_params.py | 4 +- .../agent_framework/agent_framework_helper.py | 12 ++--- .../azure_openai_response_retry.py | 20 ++++++-- src/ContentProcessorAPI/app/application.py | 1 + .../app/libs/azure/storage_blob/helper.py | 4 +- .../app/libs/base/application_base.py | 11 +++-- .../app/libs/base/fastapi_protocol.py | 2 +- .../app/routers/claimprocessor.py | 6 ++- .../src/Components/Header/Header.tsx | 2 +- .../UploadContent/UploadFilesModal.tsx | 2 +- .../src/Hooks/useFileType.test.ts | 2 +- .../ProcessQueueGrid/ProcessQueueGrid.tsx | 4 +- .../src/Pages/DefaultPage/PanelCenter.tsx | 1 - .../src/Pages/DefaultPage/PanelRight.tsx | 1 - .../src/store/slices/centerPanelSlice.test.ts | 1 - .../agent_framework/agent_framework_helper.py | 18 ++++--- .../azure_openai_response_retry.py | 20 ++++++-- .../src/main_service.py | 7 ++- .../src/services/content_process_service.py | 3 +- .../src/services/queue_service.py | 49 +++++++++++++++---- .../src/utils/http_request.py | 6 ++- .../tests/conftest.py | 3 +- .../test_application_context_di.py | 2 +- .../tests/unit/steps/test_rai_executor.py | 1 - 24 files changed, 128 insertions(+), 54 deletions(-) diff --git a/infra/scripts/validate_bicep_params.py b/infra/scripts/validate_bicep_params.py index 9c5db6da..34ea8d48 100644 --- a/infra/scripts/validate_bicep_params.py +++ b/infra/scripts/validate_bicep_params.py @@ -108,7 +108,9 @@ def parse_parameters_env_vars(json_path: Path) -> dict[str, list[str]]: data = json.loads(sanitized) params = data.get("parameters", {}) except json.JSONDecodeError: - pass + # Keep validation resilient for partially templated/malformed files: + # if JSON parsing fails, treat as having no parsable parameters. + params = {} # Walk each top-level parameter and scan its entire serialized value # for ${VAR} references from the original text. diff --git a/src/ContentProcessor/src/libs/agent_framework/agent_framework_helper.py b/src/ContentProcessor/src/libs/agent_framework/agent_framework_helper.py index 572aa3c7..de778b6e 100644 --- a/src/ContentProcessor/src/libs/agent_framework/agent_framework_helper.py +++ b/src/ContentProcessor/src/libs/agent_framework/agent_framework_helper.py @@ -143,7 +143,7 @@ def create_client( env_file_encoding: str | None = None, instruction_role: str | None = None, ) -> "AzureOpenAIChatClient": - ... + pass @overload @staticmethod @@ -166,7 +166,7 @@ def create_client( instruction_role: str | None = None, retry_config: RateLimitRetryConfig | None = None, ) -> AzureOpenAIChatClientWithRetry: - ... + pass @overload @staticmethod @@ -190,7 +190,7 @@ def create_client( env_file_path: str | None = None, env_file_encoding: str | None = None, ) -> "AzureOpenAIAssistantsClient": - ... + pass @overload @staticmethod @@ -212,7 +212,7 @@ def create_client( env_file_encoding: str | None = None, instruction_role: str | None = None, ) -> "AzureOpenAIResponsesClient": - ... + pass @overload @staticmethod @@ -235,7 +235,7 @@ def create_client( instruction_role: str | None = None, retry_config: RateLimitRetryConfig | None = None, ) -> AzureOpenAIResponseClientWithRetry: - ... + pass @overload @staticmethod @@ -252,7 +252,7 @@ def create_client( env_file_path: str | None = None, env_file_encoding: str | None = None, ) -> "AzureAIAgentClient": - ... + pass @staticmethod def create_client( diff --git a/src/ContentProcessor/src/libs/agent_framework/azure_openai_response_retry.py b/src/ContentProcessor/src/libs/agent_framework/azure_openai_response_retry.py index ee84eb94..32b0f187 100644 --- a/src/ContentProcessor/src/libs/agent_framework/azure_openai_response_retry.py +++ b/src/ContentProcessor/src/libs/agent_framework/azure_openai_response_retry.py @@ -616,8 +616,15 @@ async def _tail(): if callable(close): try: await close() - except Exception: - pass + except Exception as close_exc: + # Best-effort stream cleanup: ignore close failures so we preserve + # the original exception/retry path. + logger.debug( + "[AOAI_RETRY_STREAM] ignoring stream close failure during retry handling: %s", + _format_exc_brief(close_exc) + if isinstance(close_exc, BaseException) + else str(close_exc), + ) # One-shot retry for context-length failures. if ( @@ -802,8 +809,13 @@ async def _tail(): if callable(close): try: await close() - except Exception: - pass + except Exception as close_error: + # Intentionally suppress close-time failures so we do not + # mask the original streaming exception that triggered retry handling. + logger.debug( + "[AOAI_RETRY_STREAM] ignoring stream close failure during error handling", + exc_info=close_error, + ) # One-shot retry for context-length failures. if ( diff --git a/src/ContentProcessorAPI/app/application.py b/src/ContentProcessorAPI/app/application.py index fb4a0448..a0e3d368 100644 --- a/src/ContentProcessorAPI/app/application.py +++ b/src/ContentProcessorAPI/app/application.py @@ -53,6 +53,7 @@ class Application(Application_Base): def __init__(self): super().__init__(env_file_path=os.path.join(os.path.dirname(__file__), ".env")) + self.bootstrap() def initialize(self): """Build the FastAPI app, attach middleware, routers, and dependencies. diff --git a/src/ContentProcessorAPI/app/libs/azure/storage_blob/helper.py b/src/ContentProcessorAPI/app/libs/azure/storage_blob/helper.py index 355c9fcf..2edefdad 100644 --- a/src/ContentProcessorAPI/app/libs/azure/storage_blob/helper.py +++ b/src/ContentProcessorAPI/app/libs/azure/storage_blob/helper.py @@ -7,6 +7,7 @@ retrieve them during downstream pipeline stages. """ +from azure.core.exceptions import ResourceNotFoundError from azure.storage.blob import BlobServiceClient from app.utils.azure_credential_utils import get_azure_credential @@ -124,7 +125,8 @@ def delete_blob_and_cleanup(self, blob_name, container_name=None): container_client = self._get_container_client(container_name) try: container_client.delete_blob(blob_name) - except Exception: + except ResourceNotFoundError: + # Blob already absent; continue with folder cleanup checks. pass blobs = container_client.list_blobs() diff --git a/src/ContentProcessorAPI/app/libs/base/application_base.py b/src/ContentProcessorAPI/app/libs/base/application_base.py index a4821a13..f0311401 100644 --- a/src/ContentProcessorAPI/app/libs/base/application_base.py +++ b/src/ContentProcessorAPI/app/libs/base/application_base.py @@ -4,8 +4,10 @@ """Abstract base for the application bootstrap sequence. Orchestrates the startup order: load .env → read Azure App Configuration → -populate AppContext with configuration and credentials → configure logging → -call the concrete ``initialize()`` implemented by the subclass. +populate AppContext with configuration and credentials → configure logging. +The concrete ``initialize()`` hook is invoked +explicitly via ``bootstrap()`` +after construction is complete. """ import inspect @@ -53,14 +55,13 @@ def initialize(self): ) def __init__(self, env_file_path: str | None = None, **data): - """Execute the full bootstrap sequence. + """Execute base bootstrap setup. Steps: 1. Load ``.env`` from *env_file_path* (or derive from subclass location). 2. Read Azure App Configuration and inject values into ``os.environ``. 3. Populate ``application_context`` with config and Azure credentials. 4. Configure Python logging if enabled in config. - 5. Call ``self.initialize()``. Args: env_file_path: Explicit path to a ``.env`` file (optional). @@ -103,6 +104,8 @@ def __init__(self, env_file_path: str | None = None, **data): ): logging.getLogger(logger_name).setLevel(azure_level) + def bootstrap(self): + """Run subclass initialization after construction has completed.""" self.initialize() def _load_env(self, env_file_path: str | None = None): diff --git a/src/ContentProcessorAPI/app/libs/base/fastapi_protocol.py b/src/ContentProcessorAPI/app/libs/base/fastapi_protocol.py index 2c86b91e..34f48bec 100644 --- a/src/ContentProcessorAPI/app/libs/base/fastapi_protocol.py +++ b/src/ContentProcessorAPI/app/libs/base/fastapi_protocol.py @@ -24,7 +24,7 @@ class FastAPIWithContext(Protocol): app_context: AppContext def include_router(self, *args, **kwargs) -> None: - ... + pass def add_app_context_to_fastapi( diff --git a/src/ContentProcessorAPI/app/routers/claimprocessor.py b/src/ContentProcessorAPI/app/routers/claimprocessor.py index 00ea5e55..5eef92a0 100644 --- a/src/ContentProcessorAPI/app/routers/claimprocessor.py +++ b/src/ContentProcessorAPI/app/routers/claimprocessor.py @@ -166,8 +166,10 @@ async def delete_claim_container(claim_id: str, request: Request = None): ) try: claim_processor.delete_claim_container(claim_id=claim_id) - except Exception: - pass + except Exception as ex: + # Best-effort cleanup: continue deleting the claim-process record even if + # the backing claim container is already missing or cannot be deleted. + print(f"Failed to delete claim container for '{claim_id}': {ex}") batch_process_repository: ClaimBatchProcessRepository = app.app_context.get_service( ClaimBatchProcessRepository diff --git a/src/ContentProcessorWeb/src/Components/Header/Header.tsx b/src/ContentProcessorWeb/src/Components/Header/Header.tsx index 3dfad92d..0202dbe8 100644 --- a/src/ContentProcessorWeb/src/Components/Header/Header.tsx +++ b/src/ContentProcessorWeb/src/Components/Header/Header.tsx @@ -8,7 +8,7 @@ import React from "react"; import { useNavigate, useLocation } from "react-router-dom"; -import { useHeaderHooks, Header } from "../../Hooks/useHeaderHooks"; +import { Header } from "../../Hooks/useHeaderHooks"; import { TabList, Tab, diff --git a/src/ContentProcessorWeb/src/Components/UploadContent/UploadFilesModal.tsx b/src/ContentProcessorWeb/src/Components/UploadContent/UploadFilesModal.tsx index de077d96..97f1d453 100644 --- a/src/ContentProcessorWeb/src/Components/UploadContent/UploadFilesModal.tsx +++ b/src/ContentProcessorWeb/src/Components/UploadContent/UploadFilesModal.tsx @@ -337,7 +337,7 @@ const UploadFilesModal: React.FC = ({ open, onClose }) => setFileErrors({}) setUploadCompleted(false); setFileSchemas({}); - } + }; const onCloseHandler = () => { resetState(); onClose(); diff --git a/src/ContentProcessorWeb/src/Hooks/useFileType.test.ts b/src/ContentProcessorWeb/src/Hooks/useFileType.test.ts index 960e8926..afe4078a 100644 --- a/src/ContentProcessorWeb/src/Hooks/useFileType.test.ts +++ b/src/ContentProcessorWeb/src/Hooks/useFileType.test.ts @@ -5,7 +5,7 @@ * @file Tests for useFileType — MIME type resolution based on file extension. */ -import { renderHook, act } from '@testing-library/react'; +import { renderHook } from '@testing-library/react'; import useFileType from './useFileType'; import type { FileWithExtension } from './useFileType'; diff --git a/src/ContentProcessorWeb/src/Pages/DefaultPage/Components/ProcessQueueGrid/ProcessQueueGrid.tsx b/src/ContentProcessorWeb/src/Pages/DefaultPage/Components/ProcessQueueGrid/ProcessQueueGrid.tsx index e4f0193f..9db7210c 100644 --- a/src/ContentProcessorWeb/src/Pages/DefaultPage/Components/ProcessQueueGrid/ProcessQueueGrid.tsx +++ b/src/ContentProcessorWeb/src/Pages/DefaultPage/Components/ProcessQueueGrid/ProcessQueueGrid.tsx @@ -18,9 +18,7 @@ import { import { Tooltip, Button } from "@fluentui/react-components"; import { TableBody, TableCell, TableRow, Table, - TableHeader, TableHeaderCell, TableCellLayout, createTableColumn, useTableFeatures, - useTableSelection, useTableSort, TableColumnId, - TableRowId + TableHeader, TableHeaderCell, TableCellLayout } from "@fluentui/react-components"; import { useDispatch, useSelector, shallowEqual } from "react-redux"; diff --git a/src/ContentProcessorWeb/src/Pages/DefaultPage/PanelCenter.tsx b/src/ContentProcessorWeb/src/Pages/DefaultPage/PanelCenter.tsx index 14976f4d..0481b0b1 100644 --- a/src/ContentProcessorWeb/src/Pages/DefaultPage/PanelCenter.tsx +++ b/src/ContentProcessorWeb/src/Pages/DefaultPage/PanelCenter.tsx @@ -34,7 +34,6 @@ import { saveClaimComment, fetchContentJsonData, setActiveProcessId, - setModifiedResult, } from '../../store/slices/centerPanelSlice'; import { startLoader, stopLoader } from "../../store/slices/loaderSlice"; import { setRefreshGrid } from "../../store/slices/leftPanelSlice"; diff --git a/src/ContentProcessorWeb/src/Pages/DefaultPage/PanelRight.tsx b/src/ContentProcessorWeb/src/Pages/DefaultPage/PanelRight.tsx index 2931f083..7d0db3cd 100644 --- a/src/ContentProcessorWeb/src/Pages/DefaultPage/PanelRight.tsx +++ b/src/ContentProcessorWeb/src/Pages/DefaultPage/PanelRight.tsx @@ -14,7 +14,6 @@ import { bundleIcon, ChevronDoubleLeft20Filled, ChevronDoubleLeft20Regular } fro import { useDispatch, useSelector, shallowEqual } from 'react-redux'; import { AppDispatch, RootState } from '../../store'; import { fetchContentFileData } from '../../store/slices/rightPanelSlice'; -import { updatePanelCollapse } from "../../store/slices/defaultPageSlice"; import PanelToolbar from "../../Hooks/usePanelHooks"; import DocumentViewer from '../../Components/DocumentViewer/DocumentViewer'; diff --git a/src/ContentProcessorWeb/src/store/slices/centerPanelSlice.test.ts b/src/ContentProcessorWeb/src/store/slices/centerPanelSlice.test.ts index f27a3876..23daf308 100644 --- a/src/ContentProcessorWeb/src/store/slices/centerPanelSlice.test.ts +++ b/src/ContentProcessorWeb/src/store/slices/centerPanelSlice.test.ts @@ -118,7 +118,6 @@ describe('centerPanelSlice', () => { }); it('should set cError and clear contentData on rejected', () => { - const error = new Error('Server error'); const action = { type: fetchContentJsonData.rejected.type, error: { message: 'Server error' }, diff --git a/src/ContentProcessorWorkflow/src/libs/agent_framework/agent_framework_helper.py b/src/ContentProcessorWorkflow/src/libs/agent_framework/agent_framework_helper.py index ceb3f1ab..e2c9c9fb 100644 --- a/src/ContentProcessorWorkflow/src/libs/agent_framework/agent_framework_helper.py +++ b/src/ContentProcessorWorkflow/src/libs/agent_framework/agent_framework_helper.py @@ -142,7 +142,8 @@ def create_client( # noqa: E704 env_file_path: str | None = None, env_file_encoding: str | None = None, instruction_role: str | None = None, - ) -> "AzureOpenAIChatClient": ... + ) -> "AzureOpenAIChatClient": + pass @overload @staticmethod @@ -164,7 +165,8 @@ def create_client( # noqa: E704 env_file_encoding: str | None = None, instruction_role: str | None = None, retry_config: RateLimitRetryConfig | None = None, - ) -> AzureOpenAIChatClientWithRetry: ... + ) -> AzureOpenAIChatClientWithRetry: + pass @overload @staticmethod @@ -187,7 +189,8 @@ def create_client( # noqa: E704 async_client: object | None = None, env_file_path: str | None = None, env_file_encoding: str | None = None, - ) -> "AzureOpenAIAssistantsClient": ... + ) -> "AzureOpenAIAssistantsClient": + raise NotImplementedError @overload @staticmethod @@ -208,7 +211,8 @@ def create_client( # noqa: E704 env_file_path: str | None = None, env_file_encoding: str | None = None, instruction_role: str | None = None, - ) -> "AzureOpenAIResponsesClient": ... + ) -> "AzureOpenAIResponsesClient": + pass @overload @staticmethod @@ -230,7 +234,8 @@ def create_client( # noqa: E704 env_file_encoding: str | None = None, instruction_role: str | None = None, retry_config: RateLimitRetryConfig | None = None, - ) -> AzureOpenAIResponseClientWithRetry: ... + ) -> AzureOpenAIResponseClientWithRetry: + raise NotImplementedError @overload @staticmethod @@ -246,7 +251,8 @@ def create_client( # noqa: E704 async_credential: object | None = None, env_file_path: str | None = None, env_file_encoding: str | None = None, - ) -> "AzureAIAgentClient": ... + ) -> "AzureAIAgentClient": + pass @staticmethod def create_client( diff --git a/src/ContentProcessorWorkflow/src/libs/agent_framework/azure_openai_response_retry.py b/src/ContentProcessorWorkflow/src/libs/agent_framework/azure_openai_response_retry.py index 1b9a32b2..e3f74fcf 100644 --- a/src/ContentProcessorWorkflow/src/libs/agent_framework/azure_openai_response_retry.py +++ b/src/ContentProcessorWorkflow/src/libs/agent_framework/azure_openai_response_retry.py @@ -679,8 +679,15 @@ async def _tail(): if callable(close): try: await close() - except Exception: - pass + except Exception as close_error: + # Best-effort cleanup: ignore close failures so we preserve + # retry/original-error handling behavior. + logger.debug( + "[AOAI_RETRY_STREAM] ignored stream close error during cleanup: %s", + _format_exc_brief(close_error) + if isinstance(close_error, BaseException) + else str(close_error), + ) # One-shot retry for context-length failures. if ( @@ -865,8 +872,13 @@ async def _tail(): if callable(close): try: await close() - except Exception: - pass + except Exception as close_err: + logger.debug( + "[AOAI_RETRY_STREAM] ignoring stream close error during cleanup: %s", + _format_exc_brief(close_err) + if isinstance(close_err, BaseException) + else str(close_err), + ) # One-shot retry for context-length failures. if ( diff --git a/src/ContentProcessorWorkflow/src/main_service.py b/src/ContentProcessorWorkflow/src/main_service.py index 66ba43db..268bf48c 100644 --- a/src/ContentProcessorWorkflow/src/main_service.py +++ b/src/ContentProcessorWorkflow/src/main_service.py @@ -370,8 +370,11 @@ async def run_queue_service( try: if app.queue_service: await app.queue_service.stop_service() - except Exception: - pass + except Exception as cleanup_error: + logger.debug( + "Ignoring cleanup error while re-raising original failure: %s", + cleanup_error, + ) raise diff --git a/src/ContentProcessorWorkflow/src/services/content_process_service.py b/src/ContentProcessorWorkflow/src/services/content_process_service.py index 7b1e447f..4ddf49e0 100644 --- a/src/ContentProcessorWorkflow/src/services/content_process_service.py +++ b/src/ContentProcessorWorkflow/src/services/content_process_service.py @@ -10,6 +10,7 @@ """ import asyncio +import inspect import json import logging import uuid @@ -295,7 +296,7 @@ async def poll_status( if on_poll is not None: poll_handler = on_poll(result) - if asyncio.iscoroutine(poll_handler): + if inspect.isawaitable(poll_handler): await poll_handler status = result.get("status", "processing") diff --git a/src/ContentProcessorWorkflow/src/services/queue_service.py b/src/ContentProcessorWorkflow/src/services/queue_service.py index 66bd3d1e..18d802ee 100644 --- a/src/ContentProcessorWorkflow/src/services/queue_service.py +++ b/src/ContentProcessorWorkflow/src/services/queue_service.py @@ -106,8 +106,12 @@ def parse_claim_task_parameters_from_queue_content( try: content = decoded.decode("utf-8") except UnicodeDecodeError: + # Decoded bytes are not UTF-8; keep original content and let the + # JSON validation path below raise a clear payload-format error. pass except Exception: + # Not valid base64 (common for plain JSON payloads); keep original + # content and continue normal JSON parsing. pass content = content.strip() @@ -410,18 +414,27 @@ async def stop_service(self): if self.main_queue: self.main_queue.close() except Exception: - pass + logger.debug( + "Ignoring error while closing main queue client during shutdown.", + exc_info=True, + ) try: if self.dead_letter_queue: self.dead_letter_queue.close() except Exception: - pass + logger.debug( + "Ignoring dead-letter queue close error during shutdown.", + exc_info=True, + ) try: self.queue_service.close() except Exception: - pass + logger.debug( + "Ignoring error while closing queue service client during shutdown.", + exc_info=True, + ) async def force_stop(self): """Alias for ``stop_service()`` (stop already cancels worker tasks).""" @@ -510,8 +523,15 @@ async def stop_process( process_id, target_worker_id, ) - except Exception: - pass + except Exception as exc: + # Best-effort kill path: preserve behavior by not failing the + # request, but record unexpected cancellation/await errors. + logger.warning( + "Unexpected error while finalizing cancellation for process_id=%s worker_id=%s: %s", + process_id, + target_worker_id, + exc, + ) return True @@ -1003,7 +1023,7 @@ async def _process_queue_message(self, worker_id: int, queue_message: QueueMessa except Exception as e: workflow_error = e finally: - claim_processor = None + pass execution_time = time.time() - message_start_time @@ -1069,8 +1089,15 @@ async def _process_queue_message(self, worker_id: int, queue_message: QueueMessa claim_process_id_for_cleanup=None, worker_id=worker_id, ) - except Exception: - pass + except Exception as dead_letter_error: + # Intentionally swallow to keep worker loop alive in this last-resort path. + # We still log the failure for diagnostics/alerting. + logger.exception( + "[worker %s] failed while handling fallback failure path for message_id=%s: %s", + worker_id, + getattr(queue_message, "id", ""), + dead_letter_error, + ) finally: if renew_task is not None: renew_task.cancel() @@ -1280,7 +1307,11 @@ async def _handle_failed_no_retry( visibility_timeout=max(60, retry_delay_s), ) except Exception: - pass + logger.exception( + "Failed to extend visibility timeout after DLQ send failure; message may be retried sooner than expected (message_id=%s worker_id=%s)", + getattr(queue_message, "id", None), + worker_id, + ) return # Cleanup: diff --git a/src/ContentProcessorWorkflow/src/utils/http_request.py b/src/ContentProcessorWorkflow/src/utils/http_request.py index b62ebdeb..a6b3c0d0 100644 --- a/src/ContentProcessorWorkflow/src/utils/http_request.py +++ b/src/ContentProcessorWorkflow/src/utils/http_request.py @@ -18,6 +18,7 @@ from __future__ import annotations import asyncio +import inspect import json import time from dataclasses import dataclass @@ -162,6 +163,8 @@ def __call__(self, retry_state: RetryCallState) -> float: if ra is not None: return min(max(ra, self._min), self._max) except Exception: + # Intentionally ignore non-critical errors while inspecting Retry-After + # and fall back to exponential backoff below. pass attempt = max(retry_state.attempt_number, 1) @@ -580,6 +583,7 @@ async def post_multipart_json( try: h.close() except Exception: + # Best-effort cleanup: do not let close() failures mask the main request result. pass async def poll_until_done( @@ -630,7 +634,7 @@ async def poll_until_done( if on_poll is not None: maybe_awaitable = on_poll(resp) - if asyncio.iscoroutine(maybe_awaitable): + if inspect.isawaitable(maybe_awaitable): await maybe_awaitable if resp.status in done: diff --git a/src/ContentProcessorWorkflow/tests/conftest.py b/src/ContentProcessorWorkflow/tests/conftest.py index ce7014b5..d7df7cec 100644 --- a/src/ContentProcessorWorkflow/tests/conftest.py +++ b/src/ContentProcessorWorkflow/tests/conftest.py @@ -4,6 +4,7 @@ """Shared pytest fixtures and configuration for the test suite.""" +import importlib import sys from pathlib import Path @@ -17,7 +18,7 @@ # pick up our `src/sitecustomize.py` unless `PYTHONPATH=src` is set. Import it # explicitly after adding `src/` to `sys.path` so test collection works. try: - import sitecustomize # noqa: F401 + importlib.import_module("sitecustomize") except Exception: # Tests should still be able to run even if the compatibility hook is absent. pass diff --git a/src/ContentProcessorWorkflow/tests/unit/libs/application/test_application_context_di.py b/src/ContentProcessorWorkflow/tests/unit/libs/application/test_application_context_di.py index d8668eb6..3241ef22 100644 --- a/src/ContentProcessorWorkflow/tests/unit/libs/application/test_application_context_di.py +++ b/src/ContentProcessorWorkflow/tests/unit/libs/application/test_application_context_di.py @@ -33,7 +33,7 @@ def test_caches_instance(self) -> None: assert a is b def test_with_factory(self) -> None: - ctx = AppContext().add_singleton(_S1, lambda: _S1()) + ctx = AppContext().add_singleton(_S1, _S1) a = ctx.get_service(_S1) b = ctx.get_service(_S1) assert a is b diff --git a/src/ContentProcessorWorkflow/tests/unit/steps/test_rai_executor.py b/src/ContentProcessorWorkflow/tests/unit/steps/test_rai_executor.py index b2522982..1c566c76 100644 --- a/src/ContentProcessorWorkflow/tests/unit/steps/test_rai_executor.py +++ b/src/ContentProcessorWorkflow/tests/unit/steps/test_rai_executor.py @@ -22,7 +22,6 @@ # The @handler decorator in agent_framework validates type annotations at # import time, which fails in the test environment. Patch it to a no-op # before importing the executor module. -_orig_handler = sys.modules.get("agent_framework", MagicMock()).handler # type: ignore[union-attr] with patch("agent_framework.handler", lambda fn: fn): from steps.rai.executor.rai_executor import RAIExecutor From bc0c8860cec372f056dcafe9da31392f4dfc9693 Mon Sep 17 00:00:00 2001 From: "Prekshith D J (Persistent Systems Inc)" Date: Thu, 9 Apr 2026 18:22:14 +0530 Subject: [PATCH 2/2] Removed unused import sys --- .../tests/unit/steps/test_rai_executor.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ContentProcessorWorkflow/tests/unit/steps/test_rai_executor.py b/src/ContentProcessorWorkflow/tests/unit/steps/test_rai_executor.py index 1c566c76..df66ddc1 100644 --- a/src/ContentProcessorWorkflow/tests/unit/steps/test_rai_executor.py +++ b/src/ContentProcessorWorkflow/tests/unit/steps/test_rai_executor.py @@ -11,7 +11,6 @@ from __future__ import annotations import asyncio -import sys from pathlib import Path from unittest.mock import AsyncMock, MagicMock, patch