apolloconfig/apollo · error · IllegalArgumentException
{} not exist
Error message
{} not exist What it means
Thrown by Env.valueOf(name) in the portal environment registry when the normalized name (trim + toUpperCase, with PROD→PRO and FWS→FAT aliases) is not present in the registered env map. Default registered envs are LOCAL, DEV, FAT, FWS, UAT, LPT, PRO, TOOLS, UNKNOWN. It is an IllegalArgumentException, typically HTTP 500 unless caught. This replaces the default enum valueOf so that unknown envs raise explicitly rather than silently.
Source
Thrown at apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/Env.java:158
STRING_ENV_MAP.put(name, new Env(name));
}
return STRING_ENV_MAP.get(name);
}
/**
* replace valueOf in enum But what would happened if environment not exist?
*
* @param name
* @return
* @throws IllegalArgumentException if this existed environment has no Env with the specified
* name
*/
public static Env valueOf(String name) {
name = getWellFormName(name);
if (exists(name)) {
return STRING_ENV_MAP.get(name);
} else {
throw new IllegalArgumentException(name + " not exist");
}
}
/**
* Please use {@code Env.valueOf} instead this method
*
* @param env
* @return
*/
@Deprecated
public static Env fromString(String env) {
Env environment = transformEnv(env);
Preconditions.checkArgument(environment != UNKNOWN, String.format("Env %s is invalid", env));
return environment;
}
/**
* conversion key from {@link String} to {@link Env}View on GitHub (pinned to d95fc18d11)
Solutions
- Use only registered env names; check with Env.exists(name) before calling valueOf.
- Register the custom env first via Env.addEnvironment(name) (driven by portal meta config at startup).
- Prefer Env.transformEnv(name) which returns Env.UNKNOWN instead of throwing for unrecognized input.
- Fix typos; remember PROD aliases to PRO and FWS aliases to FAT.
Example fix
// before Env env = Env.valueOf(rawEnv); // throws if unknown // after Env env = Env.exists(rawEnv) ? Env.valueOf(rawEnv) : Env.UNKNOWN; // or, for explicit registration of a new env: // Env.addEnvironment(rawEnv); Env env = Env.valueOf(rawEnv);
Defensive patterns
Strategy: validation
Validate before calling
// guard before resolving an env name
if (!Env.exists(rawEnv)) {
// either register it or reject
Env.addEnvironment(rawEnv);
}
Env env = Env.valueOf(rawEnv); Type guard
// prefer the non-throwing transformer for untrusted input Env safe = Env.transformEnv(rawEnv); // returns Env.UNKNOWN instead of throwing
Try / catch
try { env = Env.valueOf(rawEnv); }
catch (IllegalArgumentException e) { env = Env.UNKNOWN; /* or reject request */ } Prevention
- Register custom envs via Env.addEnvironment at startup.
- Use Env.exists(name) or Env.transformEnv(name) for untrusted input.
- Remember PROD→PRO and FWS→FAT aliases; other typos are not auto-corrected.
When it happens
Trigger: Calling Env.valueOf with a name not in the env set and not added via Env.addEnvironment — e.g. "SIT", "PRE", "STAGING" — or a blank/null that normalizes to "".
Common situations: Portal meta server config references an env not declared in the active env list; a new env was added to dev.meta but not registered in portal envs; client passes a custom env string; typo like "PRODD" that escapes the PROD→PRO alias.
Related errors
- Env: %s is not supported emergency publish now
- The app does not exist in the specified environment and clus
- item not exist. ID:%s
- The maximum number of items (%s) for this namespace has been
- Not supported operation
AI-assisted analysis of apolloconfig/apollo@d95fc18d11 (2026-08-14).
Data as JSON: /api/errors/831d09da2d257d6d.
Report an issue: GitHub.