Skip to content

Commit b975710

Browse files
Fixed all the code quality issues
1 parent f86687c commit b975710

File tree

24 files changed

+128
-54
lines changed

24 files changed

+128
-54
lines changed

infra/scripts/validate_bicep_params.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ def parse_parameters_env_vars(json_path: Path) -> dict[str, list[str]]:
108108
data = json.loads(sanitized)
109109
params = data.get("parameters", {})
110110
except json.JSONDecodeError:
111-
pass
111+
# Keep validation resilient for partially templated/malformed files:
112+
# if JSON parsing fails, treat as having no parsable parameters.
113+
params = {}
112114

113115
# Walk each top-level parameter and scan its entire serialized value
114116
# for ${VAR} references from the original text.

src/ContentProcessor/src/libs/agent_framework/agent_framework_helper.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def create_client(
143143
env_file_encoding: str | None = None,
144144
instruction_role: str | None = None,
145145
) -> "AzureOpenAIChatClient":
146-
...
146+
pass
147147

148148
@overload
149149
@staticmethod
@@ -166,7 +166,7 @@ def create_client(
166166
instruction_role: str | None = None,
167167
retry_config: RateLimitRetryConfig | None = None,
168168
) -> AzureOpenAIChatClientWithRetry:
169-
...
169+
pass
170170

171171
@overload
172172
@staticmethod
@@ -190,7 +190,7 @@ def create_client(
190190
env_file_path: str | None = None,
191191
env_file_encoding: str | None = None,
192192
) -> "AzureOpenAIAssistantsClient":
193-
...
193+
pass
194194

195195
@overload
196196
@staticmethod
@@ -212,7 +212,7 @@ def create_client(
212212
env_file_encoding: str | None = None,
213213
instruction_role: str | None = None,
214214
) -> "AzureOpenAIResponsesClient":
215-
...
215+
pass
216216

217217
@overload
218218
@staticmethod
@@ -235,7 +235,7 @@ def create_client(
235235
instruction_role: str | None = None,
236236
retry_config: RateLimitRetryConfig | None = None,
237237
) -> AzureOpenAIResponseClientWithRetry:
238-
...
238+
pass
239239

240240
@overload
241241
@staticmethod
@@ -252,7 +252,7 @@ def create_client(
252252
env_file_path: str | None = None,
253253
env_file_encoding: str | None = None,
254254
) -> "AzureAIAgentClient":
255-
...
255+
pass
256256

257257
@staticmethod
258258
def create_client(

src/ContentProcessor/src/libs/agent_framework/azure_openai_response_retry.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -616,8 +616,15 @@ async def _tail():
616616
if callable(close):
617617
try:
618618
await close()
619-
except Exception:
620-
pass
619+
except Exception as close_exc:
620+
# Best-effort stream cleanup: ignore close failures so we preserve
621+
# the original exception/retry path.
622+
logger.debug(
623+
"[AOAI_RETRY_STREAM] ignoring stream close failure during retry handling: %s",
624+
_format_exc_brief(close_exc)
625+
if isinstance(close_exc, BaseException)
626+
else str(close_exc),
627+
)
621628

622629
# One-shot retry for context-length failures.
623630
if (
@@ -802,8 +809,13 @@ async def _tail():
802809
if callable(close):
803810
try:
804811
await close()
805-
except Exception:
806-
pass
812+
except Exception as close_error:
813+
# Intentionally suppress close-time failures so we do not
814+
# mask the original streaming exception that triggered retry handling.
815+
logger.debug(
816+
"[AOAI_RETRY_STREAM] ignoring stream close failure during error handling",
817+
exc_info=close_error,
818+
)
807819

808820
# One-shot retry for context-length failures.
809821
if (

src/ContentProcessorAPI/app/application.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class Application(Application_Base):
5353

5454
def __init__(self):
5555
super().__init__(env_file_path=os.path.join(os.path.dirname(__file__), ".env"))
56+
self.bootstrap()
5657

5758
def initialize(self):
5859
"""Build the FastAPI app, attach middleware, routers, and dependencies.

src/ContentProcessorAPI/app/libs/azure/storage_blob/helper.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
retrieve them during downstream pipeline stages.
88
"""
99

10+
from azure.core.exceptions import ResourceNotFoundError
1011
from azure.storage.blob import BlobServiceClient
1112

1213
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):
124125
container_client = self._get_container_client(container_name)
125126
try:
126127
container_client.delete_blob(blob_name)
127-
except Exception:
128+
except ResourceNotFoundError:
129+
# Blob already absent; continue with folder cleanup checks.
128130
pass
129131

130132
blobs = container_client.list_blobs()

src/ContentProcessorAPI/app/libs/base/application_base.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
"""Abstract base for the application bootstrap sequence.
55
66
Orchestrates the startup order: load .env → read Azure App Configuration →
7-
populate AppContext with configuration and credentials → configure logging →
8-
call the concrete ``initialize()`` implemented by the subclass.
7+
populate AppContext with configuration and credentials → configure logging.
8+
The concrete ``initialize()`` hook is invoked
9+
explicitly via ``bootstrap()``
10+
after construction is complete.
911
"""
1012

1113
import inspect
@@ -53,14 +55,13 @@ def initialize(self):
5355
)
5456

5557
def __init__(self, env_file_path: str | None = None, **data):
56-
"""Execute the full bootstrap sequence.
58+
"""Execute base bootstrap setup.
5759
5860
Steps:
5961
1. Load ``.env`` from *env_file_path* (or derive from subclass location).
6062
2. Read Azure App Configuration and inject values into ``os.environ``.
6163
3. Populate ``application_context`` with config and Azure credentials.
6264
4. Configure Python logging if enabled in config.
63-
5. Call ``self.initialize()``.
6465
6566
Args:
6667
env_file_path: Explicit path to a ``.env`` file (optional).
@@ -103,6 +104,8 @@ def __init__(self, env_file_path: str | None = None, **data):
103104
):
104105
logging.getLogger(logger_name).setLevel(azure_level)
105106

107+
def bootstrap(self):
108+
"""Run subclass initialization after construction has completed."""
106109
self.initialize()
107110

108111
def _load_env(self, env_file_path: str | None = None):

src/ContentProcessorAPI/app/libs/base/fastapi_protocol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class FastAPIWithContext(Protocol):
2424
app_context: AppContext
2525

2626
def include_router(self, *args, **kwargs) -> None:
27-
...
27+
pass
2828

2929

3030
def add_app_context_to_fastapi(

src/ContentProcessorAPI/app/routers/claimprocessor.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,10 @@ async def delete_claim_container(claim_id: str, request: Request = None):
166166
)
167167
try:
168168
claim_processor.delete_claim_container(claim_id=claim_id)
169-
except Exception:
170-
pass
169+
except Exception as ex:
170+
# Best-effort cleanup: continue deleting the claim-process record even if
171+
# the backing claim container is already missing or cannot be deleted.
172+
print(f"Failed to delete claim container for '{claim_id}': {ex}")
171173

172174
batch_process_repository: ClaimBatchProcessRepository = app.app_context.get_service(
173175
ClaimBatchProcessRepository

src/ContentProcessorWeb/src/Components/Header/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import React from "react";
1010
import { useNavigate, useLocation } from "react-router-dom";
11-
import { useHeaderHooks, Header } from "../../Hooks/useHeaderHooks";
11+
import { Header } from "../../Hooks/useHeaderHooks";
1212
import {
1313
TabList,
1414
Tab,

src/ContentProcessorWeb/src/Components/UploadContent/UploadFilesModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ const UploadFilesModal: React.FC<UploadFilesModalProps> = ({ open, onClose }) =>
337337
setFileErrors({})
338338
setUploadCompleted(false);
339339
setFileSchemas({});
340-
}
340+
};
341341
const onCloseHandler = () => {
342342
resetState();
343343
onClose();

0 commit comments

Comments
 (0)