{"record":{"id":"72aee6e4412f5f52","repo":"iflytek/astron-agent","slug":"model-check-failed-businessexception-responseenum","errorCode":"MODEL_CHECK_FAILED","errorMessage":"BusinessException(ResponseEnum.MODEL_CHECK_FAILED)","messagePattern":"BusinessException\\(ResponseEnum\\.MODEL_CHECK_FAILED\\)","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/model/ModelService.java","lineNumber":175,"sourceCode":"            String responseBody = doPostModelApi(url, requestBody, headers);\n            if (isValidModelResponse(responseBody, provider)) {\n                log.info(\"Model validation passed, domain={}, endpoint={}\", request.getDomain(), url);\n                request.setApiKey(decryptedApiKey);\n                request.setEndpoint(url);\n                request.setProvider(provider);\n                saveOrUpdateModel(request);\n                return \"Model validation passed\";\n            }\n            throw new BusinessException(ResponseEnum.MODEL_NOT_COMPATIBLE_OPENAI);\n        } catch (BusinessException e) {\n            log.error(\"Model validation failed, url={}, err={}\", url, e.getMessage(), e);\n            throw e;\n        } catch (HttpClientErrorException | HttpServerErrorException e) {\n            log.error(\"Model interface call failed, url={}, http={}, body={}\", url, e.getStatusCode(), e.getResponseBodyAsString(), e);\n            throw new BusinessException(ResponseEnum.MODEL_APIKEY_ERROR);\n        } catch (Exception e) {\n            log.error(\"Model validation failed, url={}, err={}\", url, e.getMessage(), e);\n            throw new BusinessException(ResponseEnum.MODEL_CHECK_FAILED);\n        }\n    }\n\n\n    private String decryptApiKey(String apiKey) {\n        ConfigInfo modelSecretKey = configInfoMapper.selectOne(Wrappers.<ConfigInfo>lambdaQuery()\n                .eq(ConfigInfo::getCategory, \"MODEL_SECRET_KEY\")\n                .eq(ConfigInfo::getCode, \"private_key\")\n                .eq(ConfigInfo::getIsValid, 1));\n        if (modelSecretKey == null) {\n            throw new BusinessException(ResponseEnum.MODEL_API_KEY_NOT_FOUND);\n        }\n\n        try {\n            RSAPrivateKey privateKey = RSAUtil.loadPrivateKey(modelSecretKey.getValue());\n            return RSAUtil.decryptByPrivateKeyBase64(apiKey, privateKey);\n        } catch (Exception e) {\n            log.error(\"Decrypt API Key failed\", e);","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/model/ModelService.java#L157-L193","documentation":"The final catch-all in validateModel: any exception during the endpoint probe that is not a BusinessException or an HTTP status error (e.g. connection refused/timeouts as ResourceAccessException, SSL errors, JSON parse failures of the response, or a null URL) is converted to MODEL_CHECK_FAILED, meaning the model could not be validated for an unexpected reason.","triggerScenarios":"Calling validateModel when the endpoint is unreachable (DNS failure, connection refused, timeout), TLS handshake fails, the response body cannot be parsed, or an internal bug (NPE) occurs while preparing the probe request.","commonSituations":"Typo in endpoint host/port; model service behind a firewall not reachable from the backend; self-signed or expired certificates; endpoint returns malformed JSON; internal RestTemplate misconfiguration.","solutions":["Read the logged exception ('Model validation failed, url=..., err=...') to find the root cause (connect timeout vs parse error vs NPE)","Verify network reachability from the backend host: curl/telnet to the endpoint URL and port","Fix certificate issues (trusted CA, correct chain) or endpoint URL format","If the response is malformed, fix the serving endpoint to return valid OpenAI-compatible JSON"],"exampleFix":"// before\nendpoint: https://model.internal:8443  // self-signed cert -> handshake failure\n// after\nendpoint: https://model.internal:8443  // plus install proper CA cert / use trusted TLS","handlingStrategy":"try-catch","validationCode":"// reachability pre-check from the backend environment\ntry { rest.getForEntity(endpoint, String.class); } catch (ResourceAccessException e) { throw new IllegalStateException(\"endpoint unreachable: \" + e.getMessage()); }","typeGuard":"boolean endpointReachable(String url) { try { new java.net.URL(url).openConnection().connect(); return true; } catch (Exception e) { return false; } }","tryCatchPattern":"try { modelService.validateModel(req); } catch (BusinessException e) { if (ResponseEnum.MODEL_CHECK_FAILED.equals(e.getResponseEnum())) { log.error(\"unexpected validation failure for {}\", req.getEndpoint()); return 500-check-failed-see-logs; } throw e; }","preventionTips":["Test network/TLS reachability from the backend host, not just your laptop","Use valid CA-signed certificates for model endpoints","Ensure endpoints return valid JSON and proper errors instead of crashing connections","Include full endpoint URL with scheme, host, port, and version path"],"tags":["network","unexpected-error","model-validation","http"],"backgroundTag":"http-request-failed","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}