Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix(enterprise): PLTF-3259 recognize openhands.dev in staging/feature + managed-domain detection (#15304)

aivong-openhandsf012a4017c27
diff --git a/enterprise/server/constants.py b/enterprise/server/constants.py
index 37b92c11db..8aa72104d3 100644
--- a/enterprise/server/constants.py
+++ b/enterprise/server/constants.py
@@ -6,15 +6,18 @@ HOST = os.getenv('WEB_HOST', 'app.all-hands.dev').strip()
# Check if this is a feature environment
# Feature environments have a host format like {some-text}.staging.all-hands.dev
-# or {some-text}.ohe-staging.platform-team.all-hands.dev (for platform-team sandbox)
-# Just staging.all-hands.dev doesn't count as a feature environment
+# or {some-text}.staging.openhands.dev (the domain the staging/feature stack is
+# migrating to), or {some-text}.ohe-staging.platform-team.all-hands.dev (for the
+# platform-team sandbox). The bare staging host (staging.all-hands.dev /
+# staging.openhands.dev) does not count as a feature environment.
+STAGING_BASE_HOSTS = ('staging.all-hands.dev', 'staging.openhands.dev')
IS_STAGING_ENV = bool(
- re.match(r'^.+\.staging\.all-hands\.dev$', HOST)
+ re.match(r'^.+\.staging\.(?:all-hands|openhands)\.dev$', HOST)
or re.match(r'^.+\.ohe-staging\.platform-team\.all-hands\.dev$', HOST)
- or HOST == 'staging.all-hands.dev'
+ or HOST in STAGING_BASE_HOSTS
) # Includes the staging deployment + feature deployments
IS_FEATURE_ENV = (
- IS_STAGING_ENV and HOST != 'staging.all-hands.dev'
+ IS_STAGING_ENV and HOST not in STAGING_BASE_HOSTS
) # Does not include the staging deployment
IS_LOCAL_ENV = bool(HOST == 'localhost')
@@ -33,6 +36,7 @@ def _is_all_hands_managed_domain(host: str) -> bool:
or host == 'app.openhands.ai'
or host.endswith('.all-hands.dev')
or host.endswith('.openhands.ai')
+ or host.endswith('.openhands.dev')
)
diff --git a/enterprise/tests/unit/server/test_constants.py b/enterprise/tests/unit/server/test_constants.py
index 416ef383e8..cb887b8f8d 100644
--- a/enterprise/tests/unit/server/test_constants.py
+++ b/enterprise/tests/unit/server/test_constants.py
@@ -22,6 +22,10 @@ class TestDeploymentMode:
('feature-123.staging.all-hands.dev', 'cloud'),
('pr-456.staging.all-hands.dev', 'cloud'),
('app.openhands.ai', 'cloud'),
+ # openhands.dev is also an All-Hands managed domain
+ ('app.openhands.dev', 'cloud'),
+ ('staging.openhands.dev', 'cloud'),
+ ('pr-456.staging.openhands.dev', 'cloud'),
# Customer domains should return 'self_hosted'
('openhands.acme.com', 'self_hosted'),
('internal.company.io', 'self_hosted'),
@@ -81,9 +85,13 @@ class TestDeploymentMode:
('staging.all-hands.dev', True),
('feature.staging.all-hands.dev', True),
('app.openhands.ai', True),
+ ('app.openhands.dev', True),
+ ('staging.openhands.dev', True),
+ ('pr-1.staging.openhands.dev', True),
('localhost', False), # localhost is not a managed domain
('customer.example.com', False),
('all-hands.dev', False),
+ ('openhands.dev', False), # apex is not a subdomain, so not managed
],
)
def test_is_all_hands_managed_domain(self, host: str, expected: bool):
@@ -110,6 +118,45 @@ class TestDeploymentMode:
assert constants_module.DEPLOYMENT_MODE == 'cloud'
+class TestStagingAndFeatureEnvDetection:
+ """IS_STAGING_ENV / IS_FEATURE_ENV must recognize both the legacy
+ all-hands.dev and the new openhands.dev staging/feature hosts."""
+
+ @pytest.mark.parametrize(
+ 'web_host,is_staging,is_feature',
+ [
+ # Bare staging hosts: a staging env, but NOT a feature env
+ ('staging.all-hands.dev', True, False),
+ ('staging.openhands.dev', True, False),
+ # Feature / preview hosts on both domains
+ ('feature-123.staging.all-hands.dev', True, True),
+ ('pr-279.staging.all-hands.dev', True, True),
+ ('pr-279.staging.openhands.dev', True, True),
+ ('feature-123.staging.openhands.dev', True, True),
+ # Platform-team sandbox
+ ('pr-279.ohe-staging.platform-team.all-hands.dev', True, True),
+ # Production / customer / local hosts are neither
+ ('app.all-hands.dev', False, False),
+ ('app.openhands.dev', False, False),
+ ('openhands.acme.com', False, False),
+ ('localhost', False, False),
+ ],
+ )
+ def test_staging_and_feature_env_detection(
+ self, web_host: str, is_staging: bool, is_feature: bool
+ ):
+ """WEB_HOST drives IS_STAGING_ENV / IS_FEATURE_ENV for both domains."""
+ with patch.dict('os.environ', {'WEB_HOST': web_host}):
+ import importlib
+
+ import server.constants as constants_module
+
+ importlib.reload(constants_module)
+
+ assert constants_module.IS_STAGING_ENV is is_staging
+ assert constants_module.IS_FEATURE_ENV is is_feature
+
+
class TestDeploymentModeInConfig:
"""Tests for DEPLOYMENT_MODE being exposed in config API."""