{"record":{"id":"b247251d7a63d3f2","repo":"binarywang/WxJava","slug":"s-b24725","errorCode":null,"errorMessage":"无法找到对应【%s】的小程序配置信息，请核实！","messagePattern":"无法找到对应【(.+?)】的小程序配置信息，请核实！","errorType":"exception","errorClass":"WxRuntimeException","httpStatus":null,"severity":"error","filePath":"weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java","lineNumber":598,"sourceCode":"    return switchoverTo(miniAppId, null);\n  }\n\n  @Override\n  public WxMaService switchoverTo(String miniAppId, Function<String, WxMaConfig> func) {\n    if (this.configMap.containsKey(miniAppId)) {\n      WxMaConfigHolder.set(miniAppId);\n      return this;\n    }\n\n    if (func != null) {\n      WxMaConfig config = func.apply(miniAppId);\n      if (config != null) {\n        this.addConfig(miniAppId, config);\n        return this;\n      }\n    }\n\n    throw new WxRuntimeException(String.format(\"无法找到对应【%s】的小程序配置信息，请核实！\", miniAppId));\n  }\n\n  @Override\n  public boolean switchover(String mpId) {\n    if (this.configMap.containsKey(mpId)) {\n      WxMaConfigHolder.set(mpId);\n      return true;\n    }\n\n    log.error(\"无法找到对应【{}】的小程序配置信息，请核实！\", mpId);\n    return false;\n  }\n\n  @Override\n  public void setRetrySleepMillis(int retrySleepMillis) {\n    this.retrySleepMillis = retrySleepMillis;\n  }\n","sourceCodeStart":580,"sourceCodeEnd":616,"githubUrl":"https://github.com/binarywang/WxJava/blob/1c43293a3c2c9d7e91304b6d037fb017f680d0c6/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java#L580-L616","documentation":"Thrown as WxRuntimeException when switchoverTo(miniAppId, func) cannot find a config for the given miniAppId in configMap, and the optional Function callback either returns null or was not provided. This method is used in multi-account MiniApp management to switch the active config context.","triggerScenarios":"Calling switchoverTo('wxAbc123', func) when 'wxAbc123' is not in configMap AND func.apply('wxAbc123') returns null, or calling switchoverTo('wxAbc123') (no func) when the ID is unregistered.","commonSituations":"Typo in app ID; app not registered via addConfig() before switching; dynamic loader function fails to produce a config (e.g., database lookup returns null); multi-tenant setup where app ID comes from untrusted user input.","solutions":["Register the config before switching: maService.addConfig(miniAppId, config) then maService.switchoverTo(miniAppId)","Use switchover(mpId) which returns boolean false instead of throwing","Verify the miniAppId string exactly matches what was registered (case-sensitive)","If using a func callback, ensure it returns a non-null WxMaConfig for valid IDs"],"exampleFix":"// before\nmaService.switchoverTo(\"wxWrongId\", id -> null);\n\n// after\nmaService.addConfig(\"wxCorrectId\", wxMaConfig);\nmaService.switchoverTo(\"wxCorrectId\");","handlingStrategy":"validation","validationCode":"// Check if config exists before calling switchoverTo\nif (!maService.getConfigMap().containsKey(miniAppId)) {\n  // register it first, or use the non-throwing switchover() method\n  if (!maService.switchover(miniAppId)) {\n    log.warn(\"No config for miniAppId: {}\", miniAppId);\n    return;\n  }\n}","typeGuard":"private boolean isAppRegistered(WxMaService service, String appId) {\n  return service.switchover(appId); // returns boolean, does not throw\n}","tryCatchPattern":"try {\n  maService.switchoverTo(miniAppId);\n} catch (WxRuntimeException e) {\n  if (e.getMessage().contains(\"无法找到对应\")) {\n    log.error(\"MiniApp config not found for: {}\", miniAppId);\n    // dynamically load config or skip\n  } else {\n    throw e;\n  }\n}","preventionTips":["Register all app configs via addConfig() at startup before any switchoverTo() call","Prefer switchover() (returns boolean) over switchoverTo() (throws) for untrusted app IDs","Validate the app ID source (user input, database lookup) before switching","Use a central configuration registry to ensure all app IDs are pre-registered"],"tags":["configuration","miniapp","multi-app"],"backgroundTag":null,"analyzedSha":"1c43293a3c2c9d7e91304b6d037fb017f680d0c6","analyzedAt":"2026-08-14T02:29:11.060Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}