Skip to content

fix(ima): route search folder-name hits away from document hydration - #2332

Merged
pancacake merged 1 commit into
HKUDS:devfrom
markjoin123:cursor/fix-ima-folder-matches-1b73
Nov 5, 2026
Merged

pancacake merged 1 commit into
HKUDS:devfrom
markjoin123:cursor/fix-ima-folder-matches-1b73

Conversation

@markjoin123

Copy link
Copy Markdown
Contributor

Description

search_knowledge returns folder-name matches inside info_list with a folder_ media_id and media_type 99, and no folder_id. parse_knowledge_page() only treated an entry as a folder when it had folder_id and no media_id, so these hits were parsed as documents.

Retrieval then tried to hydrate them with get_media_info, failed with ImaAPIError, spent the hydration budget, and returned content_unavailable even when real documents had matched.

Document-array entries with a folder_ media id or media_type 99 are now routed to the folder list and are never hydrated. A search that only hits folder names reports no_matches.

Related Issues

Module(s) Affected

  • services
  • tests

Checklist

  • This PR targets dev (not main).
  • I have read and followed the contribution guidelines.
  • My code follows the project's coding standards.
  • I have run pre-commit on the changed files and fixed any issues.
  • I have added relevant tests for my changes.
  • I have updated the documentation (if necessary).
  • My changes do not introduce any new security vulnerabilities.

Additional Notes

This change was AI-assisted and was reviewed and tested.

Parser regression: a live-shaped info_list entry (media_id folder_7359, media_type 99, empty highlight, no folder_id) is a folder, and a real document in the same page stays a document. The folder_ prefix and media_type 99 each suffice on their own. A media id of folder with media_type 1 stays a document.

Pipeline regression: four folder-name hits ahead of a title-only document do not call get_media_content for the folders; the document is hydrated and the result is ready. Folder-only results report no_matches with no media fetches.

python -m pytest tests/services/rag/test_ima_client_surface.py tests/services/rag/test_ima_pipeline.py tests/services/rag/test_ima_inventory.py -q
# 139 passed

python -m pytest tests/capabilities/test_ima_capability.py tests/services/rag/test_ima_inventory.py -q
# 52 passed

search_knowledge returns folder matches inside info_list with a folder_
media id and media_type 99, and no folder_id. Those were parsed as
documents, so retrieval spent the hydration budget on get_media_info
failures and reported content_unavailable.

Fixes HKUDS#2326
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants