fix(webapp): never resolve realtime streams v2 without S2 configured - #4564
fix(webapp): never resolve realtime streams v2 without S2 configured#4564matt-aitken wants to merge 3 commits into
Conversation
The default-version branch returned `REALTIME_STREAMS_DEFAULT_VERSION` verbatim while the explicit branch checked that a basin and credentials were present. A deployment that set the default to v2 without configuring S2 therefore stamped runs v2, and every read and write against those runs' streams threw for the life of the run. Both paths now go through the same check, and an unsatisfiable v2 degrades to v1, which is a working backend.
|
WalkthroughThe webapp now resolves the requested or configured realtime streams version through validated configuration. It selects v2 only when credentials and a global or per-organization basin are available. Otherwise, it selects v1. Task, batch, and replay flows now pass organization basin settings during version resolution. Tests cover deployment configurations, defaults, explicit versions, missing credentials or basins, and unrecognized versions. A changelog entry documents the fix. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Gating v2 on the global basin alone would have degraded every run to v1 on a deployment that provisions a basin per organization and sets no global one, even though S2 is fully working there. `resolveStreamBasin` already resolves run, session and organization basins ahead of the global setting, so either source now satisfies the basin requirement. Splits the pure resolver out from the env lookup so the version matrix can be tested without reaching for `env.server`.
Treating `REALTIME_STREAMS_PER_ORG_BASINS_ENABLED` as proof of a basin was wrong. The flag says the feature is on, not that an organization has been provisioned, and provisioning happens out of band. An unprovisioned organization on a deployment with no global basin would still have been stamped v2 and thrown on every stream operation, which is the failure this is meant to prevent. Callers that hold the organization now pass its `streamBasinName`, mirroring the organization step of `resolveStreamBasin`. A provisioned organization resolves v2 with no global basin configured; an unprovisioned one degrades to v1.
Summary
determineRealtimeStreamsVersiontreated its two paths differently. An explicitv2from the caller was checked against the S2 configuration before being honoured, but when the caller expressed no preference the function returnedREALTIME_STREAMS_DEFAULT_VERSIONverbatim, with no check at all.So a deployment that set the default to
v2without configuring S2 stamped its runsv2. Nothing failed at trigger time. Every later read or write against those runs' streams then threwRealtime streams v2 is required for this run but S2 configuration is missing, and because the version is fixed on the run at creation, it threw for the life of the run.Fix
Both paths now resolve through one check, in a pure function that takes the configuration rather than reading
env:An unsatisfiable
v2degrades tov1, which is a working backend, rather than producing a run whose streams cannot be used.The basin requirement
resolveStreamBasinresolves run, session and organization basins ahead of the global setting, so a deployment that provisions a basin per organization can serve v2 with no global basin at all. Gating purely on the global setting would degrade every run there to v1.determineRealtimeStreamsVersiontherefore takes an optional organization basin, and callers that hold one passauthentication.environment.organization.streamBasinName:This is deliberately the resolved basin and not the
REALTIME_STREAMS_PER_ORG_BASINS_ENABLEDflag. The flag says the feature is on, not that a given organization has been provisioned, and provisioning happens out of band. Keying off the flag would stampv2on runs for unprovisioned organizations, recreating the failure this PR removes.This does widen behaviour for explicit
v2requests, which previously required the global basin: a provisioned organization on a per-org deployment now resolvesv2where it used to getv1. That is intentional, and it makes the two paths agree.No behaviour change for a deployment that leaves
REALTIME_STREAMS_DEFAULT_VERSIONunset or set tov1and configures a global basin.Unit tests cover the resolution matrix, including organization-basin-only and credential-only configurations.