-
Notifications
You must be signed in to change notification settings - Fork 10
fix: time based state refresh for each activity #796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses an issue where stale connection data was persisting across successive workflow runs in crossover 2.0. The fix ensures that state is properly cleaned before each activity execution.
Key Changes:
- Modified state management in
_get_stateto unconditionally clean state before setting new state
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
📜 Docstring Coverage ReportRESULT: PASSED (minimum: 30.0%, actual: 75.5%) Detailed Coverage Report |
📦 Trivy Vulnerability Scan Results
Report Summary
Scan Result Details✅ No vulnerabilities found during the scan for |
📦 Trivy Secret Scan Results
Report Summary
Scan Result Details✅ No secrets found during the scan for |
|
🛠 Docs available at: https://k.atlan.dev/application-sdk/activity-state-fix |
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified FilesNo covered modified files...
|
|
🛠 Full Test Coverage Report: https://k.atlan.dev/coverage/application-sdk/pr/796 |
Bug: State Management Typo Causes Caching FailuresThe state management logic has two issues. A typo ( |
Bug: Timestamp Update Missing in Base ClassMissing timestamp update in base class |
Bug: Timestamp Handling Fails for Initial StatesThe timestamp refresh logic can fail if |
|
@abhishekagrawal-atlan - has this been tested on production instances? is this ready to merge? |
📦 Example workflows test results
|
📦 Example workflows test results
|
📦 Example workflows test results
|
This has been tested on internal instances - https://apps-framework-redshift-testing.atlan.com/. will create a ring of some production instances to test it out. |
| # Update timestamp only after successful client creation and assignment | ||
| # This ensures that if initialization fails, the old timestamp remains | ||
| # and the state can be refreshed again immediately | ||
| self._state[workflow_id].last_updated_timestamp = datetime.now() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Partial state initialization prevents automatic state refresh
The refactored _set_state method creates the state object and sets workflow_args (lines 170-177) before initializing the SQL client. If client initialization fails (lines 186-193), last_updated_timestamp is never set (line 217 not reached). On subsequent calls to _get_state, the base class check if last_updated and ... evaluates to False when last_updated is None, so it returns the broken state without attempting re-initialization. The old code called super()._set_state() first, which set last_updated_timestamp before client creation could fail, allowing time-based refresh to eventually recover. The fix could be to set last_updated_timestamp earlier, or add a check for incomplete state (e.g., sql_client is None).
Changelog
Checklist
Copyleft License Compliance
Note
Adds a 15‑minute time-based state refresh for activities and safely reinitializes SQL clients with credential loading and graceful client swap.
last_updated_timestamptoActivitiesStateand update in_set_state._get_state.last_updated_timestamp._set_stateto create/load a new SQL client (load credentials first), then close old client, assign new client/handler, and update timestamp only on success.workflow_argsduring refresh; add debug/warning logs on client close.opentelemetry-exporter-otlpto1.38.0inpyproject.toml.Written by Cursor Bugbot for commit c91d6e4. This will update automatically on new commits. Configure here.