[Core] Make cache_iterator_result preserve the chunks of items which were added
User description
Description
What - Cache_iterator_result should preserve cached items in the same chunks they're retrieved in.
Why - Some integrations have assumptions about how items are returned, and use this assumptions in other parts of the program (e.g to batch requests based on chunks of responses from an API).
How - Don't merge cache items together.
Type of change
Please leave one option from the following and delete the rest:
- [ x ] Non-breaking change (fix of existing functionality that will not change current behavior)
All tests should be run against the port production environment(using a testing org).
Core testing checklist
- [ ] Integration able to create all default resources from scratch
- [ ] Resync finishes successfully
- [ ] Resync able to create entities
- [ ] Resync able to update entities
- [ ] Resync able to detect and delete entities
- [ ] Scheduled resync able to abort existing resync and start a new one
- [ ] Tested with at least 2 integrations from scratch
- [ ] Tested with Kafka and Polling event listeners
- [ ] Tested deletion of entities that don't pass the selector
Integration testing checklist
- [ ] Integration able to create all default resources from scratch
- [ ] Completed a full resync from a freshly installed integration and it completed successfully
- [ ] Resync able to create entities
- [ ] Resync able to update entities
- [ ] Resync able to detect and delete entities
- [ ] Resync finishes successfully
- [ ] If new resource kind is added or updated in the integration, add example raw data, mapping and expected result to the
examplesfolder in the integration directory. - [ ] If resource kind is updated, run the integration with the example data and check if the expected result is achieved
- [ ] If new resource kind is added or updated, validate that live-events for that resource are working as expected
- [ ] Docs PR link here
Preflight checklist
- [ ] Handled rate limiting
- [ ] Handled pagination
- [ ] Implemented the code in async
- [ ] Support Multi account
Screenshots
Include screenshots from your environment showing how the resources of the integration will look.
API Documentation
Provide links to the API documentation used for this integration.
PR Type
Bug fix
Description
-
Preserve chunk structure in
cache_iterator_resultto maintain integration assumptions -
Changed caching logic to store and yield individual chunks separately
-
Prevents merging of cached items that breaks downstream batch processing
-
Added test to verify chunk preservation across cache hits
Diagram Walkthrough
flowchart LR
A["cache_iterator_result decorator"] -->|Before: extend| B["Merged flat list"]
A -->|After: append| C["Preserved chunks"]
C -->|On cache hit| D["Yield individual chunks"]
B -->|On cache hit| E["Yield merged list"]
File Walkthrough
| Relevant files | |||
|---|---|---|---|
| Bug fix |
| ||
| Tests |
| ||
| Documentation |
| ||
| Configuration changes |
|
PR Compliance Guide 🔍
Below is a summary of compliance checks for this PR:
| Security Compliance | |
| 🟢 | No security concerns identifiedNo security vulnerabilities detected by AI analysis. Human verification advised for critical code. |
| Ticket Compliance | |
| ⚪ | 🎫 No ticket provided
|
| Codebase Duplication Compliance | |
| ⚪ | Codebase context is not definedFollow the guide to enable codebase context checks. |
| Custom Compliance | |
| 🟢 |
Generic: Meaningful Naming and Self-Documenting CodeObjective: Ensure all identifiers clearly express their purpose and intent, making code Status: Passed
|
Generic: Secure Error HandlingObjective: To prevent the leakage of sensitive system information through error messages while Status: Passed
| |
Generic: Secure Logging PracticesObjective: To ensure logs are useful for debugging and auditing without exposing sensitive Status: Passed
| |
Generic: Security-First Input Validation and Data HandlingObjective: Ensure all data inputs are validated, sanitized, and handled securely to prevent Status: Passed
| |
| ⚪ | Generic: Comprehensive Audit TrailsObjective: To create a detailed and reliable record of critical system actions for security analysis Status: Referred Code
|
Generic: Robust Error Handling and Edge Case ManagementObjective: Ensure comprehensive error handling that provides meaningful context and graceful Status: Referred Code
| |
| |
Compliance status legend
🟢 - Fully Compliant🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label
PR Code Suggestions ✨
Explore these optional code suggestions:
| Category | Suggestion | Impact |
| High-level |
This change is potentially breakingThe modification to Examples:port_ocean/utils/cache.py [89-91]
Solution Walkthrough:Before:
After:
Suggestion importance[1-10]: 9__ Why: This suggestion correctly identifies a critical, overlooked aspect of the change: it alters the public contract of the | High |
| Possible issue |
Handle old cache format gracefullyAdd a check to handle the old cache format to prevent runtime errors. If an old port_ocean/utils/cache.py [88-91]
Suggestion importance[1-10]: 9__ Why: The suggestion correctly identifies a critical backward compatibility issue where old cache entries would cause runtime errors with the new logic, and it provides a robust, self-healing solution. | High |
| ||
Code Coverage Artifact 📈: https://github.com/port-labs/ocean/actions/runs/19710247936/artifacts/4688492598
Code Coverage Total Percentage: 88.56%
Code Coverage Artifact 📈: https://github.com/port-labs/ocean/actions/runs/19739524760/artifacts/4698705101
Code Coverage Total Percentage: 88.62%