fix(odin): Fix fetch logs result metadata - #555
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces size-limit checks on action result metadata to prevent checkin requests from being rejected by CDF due to the 512-byte limit. It implements a helper to detect oversized fields, optimizes log upload metadata by using compact numeric file IDs, and gracefully handles oversized payloads by failing actions or omitting detailed logs. The review feedback suggests making the metadata size helper more robust by casting values to strings before encoding, and refining the error handling to filter out only the oversized metadata fields rather than discarding the entire metadata dictionary.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #555 +/- ##
==========================================
+ Coverage 83.76% 83.86% +0.09%
==========================================
Files 46 46
Lines 4627 4661 +34
==========================================
+ Hits 3876 3909 +33
- Misses 751 752 +1
🚀 New features to boost your workflow:
|
|
🦄 |
Summary
Fixes the fetch_logs action so its result metadata can't exceed CDF's 512-byte-per-value limit, and prevents oversized metadata from silently poisoning the checkin batch.
Type of change
What changed
cognite/extractorutils/unstable/core/_dto.py: added MAX_METADATA_VALUE_BYTES (512) constant and oversized_metadata_fields() helper to detect metadata dict values exceeding CDF's per-value byte limit.cognite/extractorutils/unstable/core/_log_upload_action.py:cognite/extractorutils/unstable/core/base.py: in _dispatch_single_action, both the success and ActionError paths now check oversized_metadata_fields() before queuing the checkin update:tests/test_unstable/test_action_dispatch.pyandtests/test_unstable/test_log_upload_action.pycovering all of the above.Why it changed
What to focus on during review
Test evidence
test_oversized_result_metadata_fails_action_instead_of_reporting_succeeded,test_oversized_action_error_metadata_drops_metadata_but_keeps_original_message,test_max_range_with_uploads_keeps_files_metadata_within_budget,test_files_metadata_omitted_when_still_oversized.Risks and unknowns
Rollout and rollback