Skip to content

Commit 2e0e8a2

Browse files
fix: Comments fixed
1 parent 37d338b commit 2e0e8a2

4 files changed

Lines changed: 17 additions & 6 deletions

File tree

.github/workflows/broken-links-checker.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
uses: lycheeverse/lychee-action@v2.8.0
3838
with:
3939
args: >
40-
--verbose --no-progress --exclude ^https?://
40+
--verbose --no-progress --exclude ^https?:// --root-dir .
4141
${{ steps.changed-markdown-files.outputs.all_changed_files }}
4242
failIfEmpty: false
4343
env:
@@ -50,7 +50,7 @@ jobs:
5050
uses: lycheeverse/lychee-action@v2.8.0
5151
with:
5252
args: >
53-
--verbose --no-progress --exclude ^https?://
53+
--verbose --no-progress --exclude ^https?:// --root-dir .
5454
'**/*.md'
5555
failIfEmpty: false
5656
env:

src/ContentProcessor/src/libs/utils/remote_schema_loader.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,13 @@ def _download_blob_content(
103103
blob_client = blob_service_client.get_blob_client(
104104
container=container_name, blob=blob_name
105105
)
106-
return blob_client.download_blob().readall().decode("utf-8")
106+
raw_bytes = blob_client.download_blob().readall()
107+
try:
108+
return raw_bytes.decode("utf-8")
109+
except UnicodeDecodeError as exc:
110+
raise JsonSchemaLoadError(
111+
f"Schema blob '{blob_name}' is not valid UTF-8."
112+
) from exc
107113

108114

109115
class _ModelBuilder:
@@ -293,7 +299,7 @@ def _resolve_ref(self, ref: str) -> Any:
293299
name = ref[len(prefix_definitions):]
294300
else:
295301
raise JsonSchemaLoadError(
296-
f"Only local '#/$defs/...' refs are supported (got '{ref}')."
302+
f"Only local '#/$defs/...' and '#/definitions/...' refs are supported (got '{ref}')."
297303
)
298304

299305
if name in self._models:

src/ContentProcessorAPI/app/routers/logics/schema_validator.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def validate_json_schema(raw_bytes: bytes) -> dict[str, Any]:
5555
"""
5656
errors: list[str] = []
5757

58-
if raw_bytes is None:
58+
if not raw_bytes:
5959
raise SchemaValidationError(["Empty schema upload."])
6060

6161
if len(raw_bytes) > MAX_SCHEMA_BYTES:
@@ -139,6 +139,9 @@ def derive_class_name(document: dict[str, Any], fallback: str) -> str:
139139
else:
140140
candidate = fallback
141141

142+
# Apply identifier sanitization to all candidates (including title) so
143+
# that titles containing spaces/dashes/etc. cannot produce invalid
144+
# Python class names downstream.
142145
cleaned = "".join(ch if ch.isalnum() or ch == "_" else "_" for ch in candidate)
143146
if not cleaned or not (cleaned[0].isalpha() or cleaned[0] == "_"):
144147
cleaned = "Schema_" + cleaned

src/ContentProcessorAPI/app/routers/logics/schemavault.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
"""Business logic for individual schema registration, update, and deletion."""
55

6+
from typing import Literal
7+
68
from fastapi import UploadFile
79
from pydantic import BaseModel, ConfigDict, Field
810

@@ -72,7 +74,7 @@ def Update(
7274
file: UploadFile,
7375
schema_id: str,
7476
class_name: str,
75-
storage_format: str = "json",
77+
storage_format: Literal["json"] = "json",
7678
) -> Schema:
7779
"""Replace the schema file in blob storage and update Cosmos metadata."""
7880
schemas = self.mongoHelper.find_document(query={"Id": schema_id})

0 commit comments

Comments
 (0)