iflytek/astron-agent · error · BusinessException

MODEL_CHECK_FAILED

MODEL_CHECK_FAILED

Error message

BusinessException(ResponseEnum.MODEL_CHECK_FAILED)

What it means

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.

Solutions

  1. Read the logged exception ('Model validation failed, url=..., err=...') to find the root cause (connect timeout vs parse error vs NPE)
  2. Verify network reachability from the backend host: curl/telnet to the endpoint URL and port
  3. Fix certificate issues (trusted CA, correct chain) or endpoint URL format
  4. If the response is malformed, fix the serving endpoint to return valid OpenAI-compatible JSON

Example fix

// before
endpoint: https://model.internal:8443  // self-signed cert -> handshake failure
// after
endpoint: https://model.internal:8443  // plus install proper CA cert / use trusted TLS
Defensive patterns

Strategy: try-catch

Validate before calling

// reachability pre-check from the backend environment
try { rest.getForEntity(endpoint, String.class); } catch (ResourceAccessException e) { throw new IllegalStateException("endpoint unreachable: " + e.getMessage()); }

Type guard

boolean endpointReachable(String url) { try { new java.net.URL(url).openConnection().connect(); return true; } catch (Exception e) { return false; } }

Try / catch

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; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/72aee6e4412f5f52. Report an issue: GitHub.

Appendix: source

Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/model/ModelService.java:175

            String responseBody = doPostModelApi(url, requestBody, headers);
            if (isValidModelResponse(responseBody, provider)) {
                log.info("Model validation passed, domain={}, endpoint={}", request.getDomain(), url);
                request.setApiKey(decryptedApiKey);
                request.setEndpoint(url);
                request.setProvider(provider);
                saveOrUpdateModel(request);
                return "Model validation passed";
            }
            throw new BusinessException(ResponseEnum.MODEL_NOT_COMPATIBLE_OPENAI);
        } catch (BusinessException e) {
            log.error("Model validation failed, url={}, err={}", url, e.getMessage(), e);
            throw e;
        } catch (HttpClientErrorException | HttpServerErrorException e) {
            log.error("Model interface call failed, url={}, http={}, body={}", url, e.getStatusCode(), e.getResponseBodyAsString(), e);
            throw new BusinessException(ResponseEnum.MODEL_APIKEY_ERROR);
        } catch (Exception e) {
            log.error("Model validation failed, url={}, err={}", url, e.getMessage(), e);
            throw new BusinessException(ResponseEnum.MODEL_CHECK_FAILED);
        }
    }


    private String decryptApiKey(String apiKey) {
        ConfigInfo modelSecretKey = configInfoMapper.selectOne(Wrappers.<ConfigInfo>lambdaQuery()
                .eq(ConfigInfo::getCategory, "MODEL_SECRET_KEY")
                .eq(ConfigInfo::getCode, "private_key")
                .eq(ConfigInfo::getIsValid, 1));
        if (modelSecretKey == null) {
            throw new BusinessException(ResponseEnum.MODEL_API_KEY_NOT_FOUND);
        }

        try {
            RSAPrivateKey privateKey = RSAUtil.loadPrivateKey(modelSecretKey.getValue());
            return RSAUtil.decryptByPrivateKeyBase64(apiKey, privateKey);
        } catch (Exception e) {
            log.error("Decrypt API Key failed", e);

View on GitHub (pinned to 5e758547a8)