Skip to content

fix: treat undefined as not provided in mergeOptions - #53

Merged
StanislavMayorov merged 2 commits into
devfrom
fix/merge-options-undefined
Nov 18, 2026
Merged

StanislavMayorov merged 2 commits into
devfrom
fix/merge-options-undefined

Conversation

@StanislavMayorov

Copy link
Copy Markdown
Collaborator

Summary

mergeOptions let an explicit undefined replace the default at any depth. Now undefined means "not provided": it keeps the default, and a key that has no default is left out. null still overrides the default, as an explicit value.

Why

The only consumer is @adapty/capacitor, which merges user options with its defaults in getFlow, getFlowForDefaultAudience, getOnboarding, getOnboardingForDefaultAudience and preloadFlows. With core 4.3.3:

Options Before After
params: undefined TypeError before reaching native defaults (load_timeout: 5, default fetch policy)
params: { loadTimeoutMs: undefined } load_timeout: null load_timeout: 5
params: { fetchPolicy: undefined } (getFlow / getOnboarding) fetch_policy: {}, which iOS fails to decode default fetch policy
omitted / {} / regular values unchanged unchanged

The 5 s default is what the docs state for every platform, and what native applies when the field is absent. React Native does not use mergeOptions.

Tests

  • The old should handle undefined values expectation is replaced; new cases cover nested undefined, keys without defaults, inherited props, arrays, null at any depth, mergeOptions(undefined, …) and frozen defaults (toStrictEqual, so undefined keys count).
  • Core: 436/436. Capacitor's suite against this build: green, with the failing cases above fixed.

Follow-up

Patch release (4.3.4), then bump @adapty/core in Capacitor with regression tests for params: undefined.

An explicit `undefined` replaced the default at any depth, so Capacitor's
preloadFlows / getFlow / getOnboarding (and the ForDefaultAudience variants)
threw a TypeError on `params: undefined`, sent `load_timeout: null` for
`loadTimeoutMs: undefined`, and `fetch_policy: {}` for `fetchPolicy: undefined`.
Now `undefined` keeps the default, and a key with no default is omitted;
`null` still overrides, as an explicit value.
@StanislavMayorov

Copy link
Copy Markdown
Collaborator Author

@codex

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T14:15:36.297846Z 4576ad8 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 4576ad8992

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@StanislavMayorov
StanislavMayorov merged commit 3794a45 into dev Nov 18, 2026
2 checks passed
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.

1 participant