{"record":{"id":"831d09da2d257d6d","repo":"apolloconfig/apollo","slug":"not-exist","errorCode":null,"errorMessage":"{} not exist","messagePattern":"(.+?) not exist","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":500,"severity":"error","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/Env.java","lineNumber":158,"sourceCode":"      STRING_ENV_MAP.put(name, new Env(name));\n    }\n    return STRING_ENV_MAP.get(name);\n  }\n\n  /**\n   * replace valueOf in enum But what would happened if environment not exist?\n   *\n   * @param name\n   * @return\n   * @throws IllegalArgumentException if this existed environment has no Env with the specified\n   *                                  name\n   */\n  public static Env valueOf(String name) {\n    name = getWellFormName(name);\n    if (exists(name)) {\n      return STRING_ENV_MAP.get(name);\n    } else {\n      throw new IllegalArgumentException(name + \" not exist\");\n    }\n  }\n\n  /**\n   * Please use {@code Env.valueOf} instead this method\n   *\n   * @param env\n   * @return\n   */\n  @Deprecated\n  public static Env fromString(String env) {\n    Env environment = transformEnv(env);\n    Preconditions.checkArgument(environment != UNKNOWN, String.format(\"Env %s is invalid\", env));\n    return environment;\n  }\n\n  /**\n   * conversion key from {@link String} to {@link Env}","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/environment/Env.java#L140-L176","documentation":"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.","triggerScenarios":"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 \"\".","commonSituations":"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.","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."],"exampleFix":"// before\nEnv env = Env.valueOf(rawEnv); // throws if unknown\n\n// after\nEnv env = Env.exists(rawEnv) ? Env.valueOf(rawEnv) : Env.UNKNOWN;\n// or, for explicit registration of a new env:\n// Env.addEnvironment(rawEnv); Env env = Env.valueOf(rawEnv);","handlingStrategy":"validation","validationCode":"// guard before resolving an env name\nif (!Env.exists(rawEnv)) {\n  // either register it or reject\n  Env.addEnvironment(rawEnv);\n}\nEnv env = Env.valueOf(rawEnv);","typeGuard":"// prefer the non-throwing transformer for untrusted input\nEnv safe = Env.transformEnv(rawEnv); // returns Env.UNKNOWN instead of throwing","tryCatchPattern":"try { env = Env.valueOf(rawEnv); }\ncatch (IllegalArgumentException e) { env = Env.UNKNOWN; /* or reject request */ }","preventionTips":["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."],"tags":["apollo-portal","environment","config","illegal-argument"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}