Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/broken-links-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
uses: lycheeverse/lychee-action@v2.8.0
with:
args: >
--verbose --no-progress --exclude ^https?://
--verbose --no-progress --exclude ^https?:// --root-dir .
${{ steps.changed-markdown-files.outputs.all_changed_files }}
failIfEmpty: false
env:
Expand All @@ -50,7 +50,7 @@ jobs:
uses: lycheeverse/lychee-action@v2.8.0
with:
args: >
--verbose --no-progress --exclude ^https?://
--verbose --no-progress --exclude ^https?:// --root-dir .
'**/*.md'
failIfEmpty: false
env:
Expand Down
10 changes: 8 additions & 2 deletions src/ContentProcessor/src/libs/utils/remote_schema_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ def _download_blob_content(
blob_client = blob_service_client.get_blob_client(
container=container_name, blob=blob_name
)
return blob_client.download_blob().readall().decode("utf-8")
raw_bytes = blob_client.download_blob().readall()
try:
return raw_bytes.decode("utf-8")
except UnicodeDecodeError as exc:
raise JsonSchemaLoadError(
f"Schema blob '{blob_name}' is not valid UTF-8."
) from exc
Comment on lines +108 to +112


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

if name in self._models:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def validate_json_schema(raw_bytes: bytes) -> dict[str, Any]:
"""
errors: list[str] = []

if raw_bytes is None:
if not raw_bytes:
raise SchemaValidationError(["Empty schema upload."])

Comment on lines +58 to 60
if len(raw_bytes) > MAX_SCHEMA_BYTES:
Expand Down Expand Up @@ -139,6 +139,9 @@ def derive_class_name(document: dict[str, Any], fallback: str) -> str:
else:
candidate = fallback

# Apply identifier sanitization to all candidates (including title) so
# that titles containing spaces/dashes/etc. cannot produce invalid
# Python class names downstream.
cleaned = "".join(ch if ch.isalnum() or ch == "_" else "_" for ch in candidate)
Comment on lines +142 to 145
if not cleaned or not (cleaned[0].isalpha() or cleaned[0] == "_"):
cleaned = "Schema_" + cleaned
Expand Down
4 changes: 3 additions & 1 deletion src/ContentProcessorAPI/app/routers/logics/schemavault.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

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

from typing import Literal

from fastapi import UploadFile
from pydantic import BaseModel, ConfigDict, Field

Expand Down Expand Up @@ -72,7 +74,7 @@ def Update(
file: UploadFile,
schema_id: str,
class_name: str,
storage_format: str = "json",
storage_format: Literal["json"] = "json",
) -> Schema:
"""Replace the schema file in blob storage and update Cosmos metadata."""
schemas = self.mongoHelper.find_document(query={"Id": schema_id})
Expand Down
Loading