mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-11 22:55:55 +05:45
a37eca4c8efb04bbbfa154341b6f0c8cc4bd25c3
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
66659ab8ef |
Raise an error for unresolved variables instead of degrading to null (#7460)
* Raise an error for unresolved variables instead of degrading to null
A `var` lookup that found nothing returned `null`, following the JSON
Logic spec. That null then coerces: `0` in a numeric comparison, `""`
in a string one. A rule that reads a dimension the SDK never supplied
therefore still produces an answer, and often the wrong one — a missing
`now` turns `{">": [expires, now]}` into `expires > 0`, which is true
for every subscription that ever existed.
An absent variable means "unknown", and unknown is not the same answer
as "no". The lookup now throws `EvaluationError.unresolvedVariable`
carrying the path, so the rule fails loudly and the SDK decides what an
unanswerable rule means. `LocalRulesEvaluator` already distinguishes an
error from a non-match: it keeps walking later rules and only throws if
none matched.
Absence a rule genuinely tolerates is opted into with the spec's own
escape hatch, `{"var": ["path", default]}`. A key that is present but
holds `null` is a known value and still resolves. `missing` and
`missing_some` exist to probe for absence and keep reporting it.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Stop pinning the rendered path for the oversized float fixture
iOS renders `1e19` as `1e+19` and Android as `1.0E19`, so pinning the
path would keep this fixture from being shared verbatim between the two
engines. The fixture is about the formatter not trapping on a value past
Int64.max, not about how that magnitude is spelled.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Apply the unresolved-variable contract to rc.lower and rc.upper
`rc.lower` arrived on main while this branch was open, carrying a
fixture that pinned a missing variable as a `typeMismatch` from the
operator. The lookup now fails first, so the error names the unresolved
path instead. Its companion pins that an explicit null still reaches
`rc.lower` and is refused there.
The operator's rationale for not coercing cited a missing `var`
resolving to null, which is no longer how that ends. It refuses
non-strings because an explicit null would lower to "null" and compare
equal to it, which is the part that still holds.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Trim the warn doc comment
Co-authored-by: Cursor <cursoragent@cursor.com>
* Name the expected-error path field for the case it belongs to
`path` sits next to `kind` and `operator` with nothing to say which
error it qualifies. The JSON key stays `path`, since there it appears
alongside `"error": "unresolvedVariable"` and reads unambiguously.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Describe the rc.rootVar fixture by what it does today
The description narrated the previous null-degrading behavior instead of
the case the fixture pins.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Give the absent-attribute predicates a default
Two non-matching predicates read attribute paths that resolve to nothing,
which is now an error rather than a false-y null. The Android counterpart
already carried this change.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Report an unanswerable audience as unavailable rather than no match
Two checkpoint tests pinned the null-degrading behavior: an audience
reading a dimension no provider supplies was merely false, so it read as
noMatch, and under negation it matched everyone.
The lookup throws now, which routes both through the resolver's existing
decision that an audience the SDK failed to evaluate is not the same
answer as an audience the customer falls outside of.
Co-authored-by: Cursor <cursoragent@cursor.com>
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
|
||
|
|
8ba422da6a |
Add rc.lower and rc.upper custom operators (#7436)
* Add Scope plumbing and custom operator extension point Thread evaluation scope through the rules engine and delegate unknown operators to an empty CustomOperators dispatcher, without changing behavior. Co-authored-by: Cursor <cursoragent@cursor.com> * Fix project.pbxproj: restore RewardedAdTrackingMetadata entries The RulesEngine registration edit accidentally dropped four RewardedAdTrackingMetadata.swift entries from the Xcode project. Restore them and normalize CustomOperators identifiers to 24 hex chars. Co-authored-by: Cursor <cursoragent@cursor.com> * Promote firstArgEvaluated to shared Operators helpers Move the unary-arg helper from LogicOperators to Operators so custom operators can use the same json-logic-js spread convention. Co-authored-by: Cursor <cursoragent@cursor.com> * Add rc.lower and rc.upper for case-insensitive rules Locale-independent case conversion via jsString coercion, with predicate fixtures covering coercion, Unicode behavior, and motivating match cases. Co-authored-by: Cursor <cursoragent@cursor.com> * Address review comments on custom operator extension point Drop the cross-engine registration note from CustomOperators, and restore the single-line var extra-args warning that was reflowed without changing its text. Co-authored-by: Cursor <cursoragent@cursor.com> * Pin locale-independent uppercasing of ASCII i rc.lower already had a fixture asserting the Unicode default mapping for the Turkish I, but rc.upper had no equivalent. The uppercase direction is the more consequential one: Turkish maps i to U+0130, a scalar with no ASCII counterpart, so a locale-sensitive implementation would silently change what rules match. Co-authored-by: Cursor <cursoragent@cursor.com> * Require string input for rc.lower and rc.upper Both operators coerced non-strings through jsString, mirroring JS String(x).toLowerCase(). That makes absent data look like real data: a missing var resolves to null, so comparing a lowercased path against "null" would quietly match. Throw typeMismatch instead, matching rc.length and rc.entries. The four coercion fixtures are replaced by nine type-error fixtures covering null, undefined, numbers, booleans, arrays, objects and missing vars, with rc.upper cases pinning that it shares the guard. Co-authored-by: Cursor <cursoragent@cursor.com> * Correct the jsNumberString divergence note The note claimed the JS mismatch only surfaces through var path coercion and looseEq, and only for large magnitudes. cat, substr and in stringify numbers through the same helper, and small values diverge too: 1e-6 renders as "1e-06" rather than "0.000001". Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com> |