Skip to content

harden datastream evaluation against rules engine failures (SCH-7057) - #102

Closed
bpapillon wants to merge 2 commits into
mainfrom
fix-datastream-null-envelope
Closed

harden datastream evaluation against rules engine failures (SCH-7057)#102
bpapillon wants to merge 2 commits into
mainfrom
fix-datastream-null-envelope

Conversation

@bpapillon

Copy link
Copy Markdown
Collaborator

Fixes the 1.3.4 regression reported by Syrto on 2026-09-04 (see SchematicHQ/schematic-api#8060 for the engine-side fix).

WASM v0.7.0 added warning_tiers without the null-tolerant deserializer, and this SDK sends "warning_tiers": null for any company that has been through a partial-update merge, because the generated models keep explicitly-set None values when dumped. Every check against such a company returned an error code, which _evaluate_flag turned into the flag default with reason="RULES_ENGINE_ERROR". Callers could not tell that from a real denial.

  • Strip None values from the envelope before it reaches the WASM, so the envelope shape no longer depends on how the models were built. Regression test runs the real partial-merge path against the bundled WASM.
  • _evaluate_flag now raises RulesEngineError (exported from schematic.datastream) instead of returning the default, so check_flag/check_flags fall back to the REST API the way they already do for other datastream failures.
  • The fallback log line moves from DEBUG to WARNING.

WASM_VERSION stays at 0.7.1 until 0.7.2 is released; the Python-side stripping makes the SDK safe on either.

The generated models keep explicitly-set None values even with
exclude_none=True, and partial_company sets every unset optional
entitlement field to None when it merges a partial update. WASM v0.7.0
rejects an explicit null for warning_tiers, so from a company's first
partial update every check against it returned an error code and the
caller saw the flag default (schematichq 1.3.4, 2026-09-04).
_evaluate_flag returned the flag default with reason RULES_ENGINE_ERROR,
so an engine failure was indistinguishable from a real verdict and never
reached the API fallback the client already has. Raise RulesEngineError
instead, and log the fallback at WARNING so an abandoned datastream
evaluation is visible without DEBUG logging.
@bpapillon bpapillon closed this Sep 4, 2026
@bpapillon
bpapillon deleted the fix-datastream-null-envelope branch September 4, 2026 21:15
@bpapillon bpapillon changed the title harden datastream evaluation against rules engine failures harden datastream evaluation against rules engine failures (SCH-7057) Sep 4, 2026
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