fix: skip llm parsing for oversized project affiliation files#4319
Conversation
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
There was a problem hiding this comment.
Pull request overview
This PR addresses multi-hour failures in the git_integration affiliation pipeline caused by very large project-registry affiliation files (e.g. cncf/devstats-example/github_users.json) being sent to Bedrock/LLM parsing. It introduces a 1 MB size guard: oversized files are marked unusable in the affiliation registry and skip LLM parsing, while file hashing is unified to always hash raw bytes on disk (decoding only when content is actually needed for parsing).
Changes:
- Add
MAX_FILE_SIZE_BYTES = 1_000_000and a pre-loados.path.getsizecheck that short-circuits LLM parsing for oversized files (first hit hashes + raisesAffiliationAnalysisError(retain_file_hash=True)→ registryUNUSABLE; steady state reuses the stored hash and skips parsing). - Replace
compute_file_hash(content: str)with asynccompute_file_hash_from_path(...), a chunked reader that hashes raw bytes and optionally retains content, fixing hash mismatches for non-UTF-8 files. - Route under-limit files through the unchanged
resolve_snapshotpath after decoding retained bytes withsafe_decode.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
| file_bytes, file_hash = await self.compute_file_hash_from_path( | ||
| file_path_on_disk, retain_content=True | ||
| ) | ||
| content = safe_decode(file_bytes) |
…iationService Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Summary
Adds a 1MB size limit for project-registry affiliation files. Files over the limit are marked
unusableand skip Bedrock parsing, preventing multi-hour failures on huge data dumps (e.g.cncf/devstats-example/github_users.json). File hashing is unified to always use raw bytes on disk, with decode only used for LLM parsing.Changes
MAX_FILE_SIZE_BYTES(1MB) toAffiliationServiceos.path.getsizebefore loading content into memoryAffiliationAnalysisErrorwithretain_file_hash=True→ registry markedunusableunusablefor same path):getsizeonly, reuse stored hash, skip LLMresolve_snapshotcompute_file_hash_from_path— single chunked reader that hashes raw bytes;retain_content=Trueonly when content is needed for parsing