From eca7a52bbec3f3839398543515329e9a4ee6c6e9 Mon Sep 17 00:00:00 2001 From: suguanYang Date: Wed, 13 May 2026 18:18:27 +0800 Subject: [PATCH 1/2] fix: resolve CodeQL redundant comparison and empty except warnings --- .../shared/services/retrieval/agent_navigate.py | 12 ++++++------ .../shared-python/shared/utils/token_estimate.py | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/shared-python/shared/services/retrieval/agent_navigate.py b/packages/shared-python/shared/services/retrieval/agent_navigate.py index 446c7d80a..3f7a2d316 100644 --- a/packages/shared-python/shared/services/retrieval/agent_navigate.py +++ b/packages/shared-python/shared/services/retrieval/agent_navigate.py @@ -605,7 +605,8 @@ async def _load_child_sections( continue # Category 2: Descendants of scope_path (children to explore) - is_descendant = parts[:scope_depth] == scope_parts and depth > scope_depth + # depth > scope_depth is guaranteed by the continue at line above + is_descendant = parts[:scope_depth] == scope_parts if is_descendant: # Skip excluded paths is_excluded = _excl and any( @@ -630,11 +631,10 @@ async def _load_child_sections( } continue else: - if depth > scope_depth: - logger.debug( - f' _load_child_sections: NOT descendant path={path!r} ' - f'parts[:scope_depth]={parts[:scope_depth]} != scope_parts={scope_parts}' - ) + logger.debug( + f' _load_child_sections: NOT descendant path={path!r} ' + f'parts[:scope_depth]={parts[:scope_depth]} != scope_parts={scope_parts}' + ) # Category 3: Everything else → pruned (not added) diff --git a/packages/shared-python/shared/utils/token_estimate.py b/packages/shared-python/shared/utils/token_estimate.py index 3b8cb4b99..9d3c635d2 100644 --- a/packages/shared-python/shared/utils/token_estimate.py +++ b/packages/shared-python/shared/utils/token_estimate.py @@ -25,6 +25,7 @@ def _get_tiktoken_encoding(model_hint: str | None): if model_hint: return tiktoken.encoding_for_model(model_hint) except Exception: + # Model hint lookup failed; fall through to cl100k_base default pass try: From 8cfa1f149de51566400698c31648245f7d461daa Mon Sep 17 00:00:00 2001 From: suguanYang Date: Wed, 13 May 2026 18:31:28 +0800 Subject: [PATCH 2/2] fix: update demo contract test to no longer reference asset_url asset_url was removed from the regular document chunk API responses in PR #46. The contract test now uses file_path instead. --- apps/api/tests/contract/test_demo_documents_contract.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/api/tests/contract/test_demo_documents_contract.py b/apps/api/tests/contract/test_demo_documents_contract.py index 3ce273ba0..abca22c68 100644 --- a/apps/api/tests/contract/test_demo_documents_contract.py +++ b/apps/api/tests/contract/test_demo_documents_contract.py @@ -174,7 +174,7 @@ async def test_should_materialize_demo_source_without_parse_or_credit_charge( ) document_chunks_response = await api_client.get( f"/api/v1/documents/{first_response.json()['sources'][0]['document_id']}" - "/chunks?include_asset_urls=true&page_size=200" + "/chunks?page_size=200" ) assert empty_cached_response.status_code == 200 @@ -261,7 +261,7 @@ async def test_should_materialize_demo_source_without_parse_or_credit_charge( assert retrieval_results[0]["source"]["document_id"] == document_id assert retrieval_results[0]["source"]["section_path"] != "Root" assert media_chunks - assert media_chunks[0]["asset_url"] + assert media_chunks[0]["file_path"] uploaded_files = fake_result_storage.raw_files_by_job_id[str(job_row["job_id"])] assert any(file_path.startswith("images/") for file_path in uploaded_files) assert any(file_path.startswith("tables/") for file_path in uploaded_files)