SDK-562 Fix offline queue replaying expired JWT - #1085
Merged
Conversation
Offline-queued requests persisted the JWT inside the task at enqueue time and replayed it on every retry. A task queued while the token was expired kept failing with a 401 after refresh, survived app restarts, and paused the JWT tasks behind it. The task processor now overwrites the persisted token with the current one from AuthManager before building the request, matching online behavior and healing tasks already stuck in the queue. A nil live token keeps the persisted one. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1085 +/- ##
==========================================
- Coverage 72.34% 72.32% -0.02%
==========================================
Files 114 114
Lines 9585 9594 +9
==========================================
+ Hits 6934 6939 +5
- Misses 2651 2655 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Requests persisted to the offline queue froze the JWT at enqueue time and replayed it on every retry. A task queued while the token was expired kept failing with a 401 even after a successful refresh, survived app restarts, and paused the JWT tasks queued behind it. Reported by Wolt (SDK-562).
Changes
IterableAPICallTaskProcessoroverwrites the decoded task's auth token with the currentAuthManagertoken before building the request, matching the online path which reads the token at send timeIterableTaskRunnerand the dependency container thread the existingAuthManagerinstance into the processor (optional parameter, nil default, so other constructions are unchanged)Impact
getAuthToken()read per offline task executionTesting
How to test:
./agent_build.shxcodebuild test -scheme swift-sdk -destination 'platform=iOS Simulator,name=iPhone 17 Pro' -only-testing:offline-events-tests(96 tests, 0 failures; full unit-tests also green, 644 tests)TaskRunnerTests.testJWTAuthFailureRetriesWithRefreshedTokenasserts the wire seesBearer expired-tokenthenBearer fresh-token;TaskProcessorTests.testUsesCurrentAuthTokenWhenProcessingPersistedTaskpins re-stamp across a restart[expired, expired], confirming it pins the reported bug