feat(webapp): org-gated internal API origin in run env vars - #4366
feat(webapp): org-gated internal API origin in run env vars#4366myftija wants to merge 6 commits into
Conversation
Deployed runs get TRIGGER_API_URL from INTERNAL_API_ORIGIN when the org's internalApiOriginEnabled feature flag resolves on (org override wins in both directions, global default otherwise). No-op unless INTERNAL_API_ORIGIN is set. Resolved at attempt start, so flag changes apply on the next attempt without redeploys.
…PI origin + unit tests
… cached flags registry Review follow-ups: the global default now comes from the in-memory globalFlagsRegistry snapshot (cold read fails safe to the public origin) instead of a per-attempt featureFlag query, and the deliberate non-switching of TRIGGER_STREAM_URL is documented.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📜 Recent review details⏰ Context from checks skipped due to timeout. (21)
WalkthroughAdds the 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 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 |
… staleness The internal-api-origin lookup used the writer client in a file that reads via $replica; flag reads tolerate snapshot staleness. Also: the resolution comment now states that a global-default flip lags by the registry reload interval per instance (only org overrides apply on the very next attempt), the invalid-override test asserts fallback to an enabled global default, and the release note is written for self-hosters.
|
… flags Read the org's feature flags off the environment already loaded at attempt start instead of a per-attempt query, and take the global default from the INTERNAL_API_ORIGIN_ENABLED env var — matching the scheduled-queue-split resolver. Both prod env-var loaders now include organization.featureFlags.
…registry Resolve the global default from the cached DB feature-flags snapshot so the admin global toggle takes effect, with INTERNAL_API_ORIGIN_ENABLED as the fallback when unset. Load organization.featureFlags only when INTERNAL_API_ORIGIN is configured.
| // Routes deployed runs' TRIGGER_API_URL to INTERNAL_API_ORIGIN. Per-org, with | ||
| // INTERNAL_API_ORIGIN_ENABLED as the global default (org wins). No-op unless | ||
| // INTERNAL_API_ORIGIN is set. | ||
| // Strict z.boolean(): coercion turns the string "false" into true, which |
There was a problem hiding this comment.
I can see you aren't using Eric'c comment killer plugin 😝
Adds an opt-in way for operators to route deployed runs' API traffic through a different origin than the public one, per organization. Set
INTERNAL_API_ORIGINon the webapp and enable theinternalApiOriginEnabledfeature flag (globally or per org, with the org override winning in both directions): deployed runs for enabled orgs then getTRIGGER_API_URLset to the internal origin instead ofAPI_ORIGIN. Useful for gradually moving run traffic onto a private network path.Design
The origin is resolved when an attempt starts, so flag changes take effect on the next attempt and roll back the same way, with no task redeploys. The org override is read fresh per attempt; the global default comes from the cached flags registry (a cold read fails safe to the public origin). When
INTERNAL_API_ORIGINis unset the flag is a no-op and no extra queries run, so existing deployments are unaffected. Dev runs always use the public origin, andTRIGGER_STREAM_URLremains unchanged.