Skip to content

[SDK-715] Parse remote config fields independently - #1112

Open
franco-zalamena-iterable wants to merge 5 commits into
feature/SDK-714-network-retry-policyfrom
feature/SDK-715-a-remote-config
Open

franco-zalamena-iterable wants to merge 5 commits into
feature/SDK-714-network-retry-policyfrom
feature/SDK-715-a-remote-config

Conversation

@franco-zalamena-iterable

@franco-zalamena-iterable franco-zalamena-iterable commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

📝 Summary

Remote config now reads offlineMode and autoRetry independently, handles a missing or wrong-typed autoRetry like iOS and keeps the saved values on a failed fetch. Unlike iOS, Android applies each field on its own.

🎟️ Jira Ticket: SDK-715

Epic: SDK-454

Stack, in order: #1111 (SDK-714), #1112, #1113, #1114, #1115. This is #1112.

📖 Description

This PR fixes the remote configuration parsing that the network retry gate depends on.

Each field is now applied on its own, so a response without offlineMode no longer stops the SDK from reading autoRetry. A missing offlineMode keeps the saved value.

A missing or null autoRetry now turns auto retry off, like iOS. Previously Android kept the last saved value. An autoRetry that is not a boolean keeps the saved value, also like iOS, so the strings "true" and "false" are no longer read as booleans. Unlike iOS, which ignores the whole response if offlineMode is missing or either field has the wrong type, Android applies each field on its own.

If the remote configuration request fails, the saved values are kept and the error body is not read as a configuration.

The remote configuration fetch keeps its success and failure handlers across a JWT retry, so the config from the retried request gets applied. This is limited to that internal call. Public calls keep the current behaviour and still get exactly one failure callback.

The remote autoRetry state now lives in an IterableRemoteRetryConfig holder that IterableApi owns and passes to IterableApiClient, so the request layer can read it without going through getInstance().

This changes the JWT retry of queued requests. A missing autoRetry is now false, so a queued request that gets a JWT 401 is removed from the queue, as it was before auto retry was enabled, and the SDK tries to re-send it after it gets a new token. The retry policy from #1111 is still not read anywhere.

Known gaps

That re-send is best-effort. If IterableAuthManager skips the token refresh, for example because a refresh is already scheduled, auth retries are paused or the app is in the background, the request is lost. This is the same on master and is not changed here.

🧪 How to test?

./gradlew :iterableapi:testDebugUnitTest gives 839 tests, 21 skipped and 0 failures. Checkstyle, lint and the androidTest compile are green. The new IterableApiTest cases cover a missing field, wrong-typed and null autoRetry, a failed fetch, the JWT retry of the config fetch and that offlineMode is saved. The auth retry handler tests in IterableRequestTaskTest are one table now, and it also checks that an offline request with an AuthRetrySuccessHandler drops both handlers on the JWT re-send.

🧾 Changelog

Added a Changed entry for the autoRetry parsing, including what happens to a queued JWT 401, and a Fixed entry for the independent field parsing and the failed fetch, under Unreleased in CHANGELOG.md.

🤖 Generated with Claude Code

Comment on lines +111 to +112
// Matching iOS, a missing or null autoRetry means disabled and a non-boolean one keeps the saved value.
Object autoRetryRemote = jsonData.isNull(IterableConstants.KEY_AUTO_RETRY) ? Boolean.FALSE : jsonData.opt(IterableConstants.KEY_AUTO_RETRY);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes Phase 1 JWT retry, and the PR body says no request retry behaviour changes.

Take a saved autoRetry=true, then a successful response {"offlineMode": true}:

  • Before: autoRetry was written only if (jsonData.has(KEY_AUTO_RETRY)), so the saved true stayed.
  • Now: isNull treats the missing key as false, and :114-115 persist and publish it.

On the next queued request that gets a JWT 401, IterableTaskRunner.java:240 (autoRetry && isJwtFailure) is now false. The 401 falls through to isPermanentFailure, so the task is deleted instead of kept and paused for auth. Meanwhile IterableRequestTask.java:306 takes the inline token-refresh branch.

The same thing happens when the response sends the strings "true"/"false" (base coerced them), when autoRetry arrives without offlineMode (base applied neither), and when an error body is no longer parsed (base could read the flag from it). SDK-715 asks for JWT autoRetry to stay on its current path while the Phase 2 switch is off.

If the iOS missing-means-false rule isn't required in this slice, keeping the base semantics is a two-line change:

Suggested change
// Matching iOS, a missing or null autoRetry means disabled and a non-boolean one keeps the saved value.
Object autoRetryRemote = jsonData.isNull(IterableConstants.KEY_AUTO_RETRY) ? Boolean.FALSE : jsonData.opt(IterableConstants.KEY_AUTO_RETRY);
// A missing, null or non-boolean autoRetry keeps the saved value.
Object autoRetryRemote = jsonData.opt(IterableConstants.KEY_AUTO_RETRY);

If it is required, please change the PR body's "does not change any request retry behaviour" and say in the CHANGELOG what happens to queued JWT-401 requests when the server stops sending autoRetry.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm keeping the iOS rule for a missing autoRetry, so i updated the PR body and the CHANGELOG to say what happens to a queued JWT 401. The re-send after the new token is best-effort, same as on master, so i also listed it as a known gap in the PR body.

Comment thread CHANGELOG.md Outdated
- Added `IterableNetworkRetryPolicy` and `IterableConfig.Builder.setNetworkRetryPolicy()` to configure retries for API requests that fail with a server error (5xx) or without a response, which covers any client-side failure including connection errors and timeouts. The policy only takes effect once enabled; when it is not enabled (the default), the SDK's existing request retry behaviour is unchanged. Once enabled, the defaults are 5 attempts, a fixed 2 second interval and a 60 second total deadline. The policy is not applied to requests yet.

### Changed
- A remote configuration response without `autoRetry` now turns JWT auto retry off, matching iOS. Previously Android kept the last saved value. An `autoRetry` that is not a boolean, such as a string or a number, keeps the saved value, also matching iOS, and the strings `"true"` and `"false"` are no longer read as booleans.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Matching iOS" holds for autoRetry on its own, but not for the response as a whole. iOS 6.7.5 decodes RemoteConfiguration as one Codable object (swift-sdk/Internal/Models.swift:17-21):

  • offlineMode: try container.decode(Bool.self, …), which throws if the key is missing, null or not a bool
  • autoRetry: try container.decodeIfPresent(Bool.self, …) ?? false, which throws if the value isn't a bool

A throw fails the whole request (NetworkHelper.swift:177-190), and checkRemoteConfiguration then logs "using saved values" and writes neither field. So:

Response iOS 6.7.5 Android (this PR)
{"autoRetry": true} (no offlineMode) keeps both saved values applies autoRetry
{"offlineMode": true, "autoRetry": "false"} keeps both saved values applies offlineMode
{} keeps both saved values turns autoRetry off

Per-field parsing is a reasonable choice, but it's a difference from iOS, not parity. The same claim appears at line 15 ("Each field is now applied on its own"), in the code comment at IterableApi.java:111, in the PR summary and description, and in commit 49d9bdbc. The tests at IterableApiTest.java:933 and :971 lock in the difference without saying so.

Suggest either state the difference wherever parity is claimed (Android applies each field on its own, while iOS ignores the whole response if a field is missing or has the wrong type), or rejecting the whole response as iOS does.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept the per field parsing, since the point of this PR is that a missing offlineMode doesn't stop autoRetry from being applied. The difference from iOS is now stated in the CHANGELOG, the code comment and the PR body.

…ers across a JWT retry

A missing offlineMode no longer stops autoRetry from being read, a missing
autoRetry now means false (iOS parity), and error responses no longer
reach the parser. The remote autoRetry state lives in
IterableRemoteRetryConfig, owned by IterableApi and passed to
IterableApiClient through its 3-arg constructor.

The remote config fetch now uses success and failure handlers, so it opts
in to keeping them on a JWT retry through AuthRetrySuccessHandler. Every
public call keeps a single onFailure after a JWT 401.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lean

Matching iOS, a string or number autoRetry no longer overwrites the saved
value, and the strings "true" and "false" are no longer read as booleans.
A missing or null autoRetry still turns it off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…used constructor

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The request isn't dropped. It's removed from the queue and the SDK tries
to re-send it after a new token, but that re-send isn't guaranteed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…bles

The remote config tests for a missing or null autoRetry and for a wrong
type autoRetry are now one table each, and the two client wiring checks
are one test. The embedded messages handler test is gone, since
updateEmail and the handler table cover the same rule.

The auth retry handler tests are one table, plus a new row for an
OFFLINE request with an AuthRetrySuccessHandler, which still drops both
handlers. Nothing pinned that half of keepsHandlersOnAuthRetry before.
Test-only change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@franco-zalamena-iterable
franco-zalamena-iterable force-pushed the feature/SDK-715-a-remote-config branch from 49d9bdb to 5c108c5 Compare November 27, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants