apache/dubbo · error · IllegalStateException
Unsupported environment: %s, only support %s/%s/%s, default
Error message
Unsupported environment: %s, only support %s/%s/%s, default is %s.
What it means
Thrown by ApplicationConfig.setEnvironment() when the environment string is not one of the three allowed values (development, test, production, as defined by DEVELOPMENT_ENVIRONMENT/TEST_ENVIRONMENT/PRODUCTION_ENVIRONMENT constants). The environment tag influences Dubbo's behavior such as the serializer/deserializer Kryo2 output and other env-aware defaults.
Source
Thrown at dubbo-common/src/main/java/org/apache/dubbo/config/ApplicationConfig.java:408
public String getArchitecture() {
return architecture;
}
public void setArchitecture(String architecture) {
this.architecture = architecture;
}
public String getEnvironment() {
return environment;
}
public void setEnvironment(String environment) {
if (environment != null
&& !(DEVELOPMENT_ENVIRONMENT.equals(environment)
|| TEST_ENVIRONMENT.equals(environment)
|| PRODUCTION_ENVIRONMENT.equals(environment))) {
throw new IllegalStateException(String.format(
"Unsupported environment: %s, only support %s/%s/%s, default is %s.",
environment,
DEVELOPMENT_ENVIRONMENT,
TEST_ENVIRONMENT,
PRODUCTION_ENVIRONMENT,
PRODUCTION_ENVIRONMENT));
}
this.environment = environment;
}
public RegistryConfig getRegistry() {
return CollectionUtils.isEmpty(registries) ? null : registries.get(0);
}
public void setRegistry(RegistryConfig registry) {
List<RegistryConfig> registries = new ArrayList<>(1);
registries.add(registry);
this.registries = registries;View on GitHub (pinned to 3a3043227f)
Solutions
- Use one of: 'development', 'test', 'production' (exact match).
- Map your custom environment name to the closest supported value before setting it.
- Omit the property entirely if you don't need environment-specific Dubbo behavior (production is the documented default).
Example fix
// before <dubbo:application name="app" environment="prod"/> // after <dubbo:application name="app" environment="production"/>
Defensive patterns
Strategy: validation
Validate before calling
import java.util.Set;
Set<String> valid = Set.of("development", "test", "production");
String env = "production";
if (env != null && !valid.contains(env)) {
throw new IllegalArgumentException("Invalid environment: " + env + ". Allowed: " + valid);
}
applicationConfig.setEnvironment(env); Type guard
static boolean isValidEnvironment(String env) {
return env == null || Set.of("development", "test", "production").contains(env);
} Try / catch
try {
applicationConfig.setEnvironment(env);
} catch (IllegalStateException e) {
if (e.getMessage().startsWith("Unsupported environment")) {
applicationConfig.setEnvironment("production"); // safe default
} else throw e;
} Prevention
- Map environment names (staging/prod) to the three allowed values.
- Do not reuse Spring profile names directly as Dubbo environment.
- Omit the property when env-specific Dubbo behavior is unneeded.
When it happens
Trigger: Setting dubbo.application.environment or ApplicationConfig.setEnvironment() to a value outside {development, test, production}, e.g. 'staging', 'qa', 'prod'.
Common situations: Teams using 'staging' or 'prod' as environment names and assuming Dubbo accepts them. Copying Spring profile names directly into the Dubbo environment property.
Related errors
- Invalid configurator rule, please specify at least one param
- service field in configuration is null.
- Illegal affinity rule!
- Illegal route rule!
- Illegal route rule!
AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14).
Data as JSON: /api/errors/721b7d19dfbf0dc0.
Report an issue: GitHub.