{"record":{"id":"e6a09b66f5ae3f14","repo":"iflytek/astron-agent","slug":"parameter-error-e6a09b","errorCode":"PARAMETER_ERROR","errorMessage":"PARAMETER_ERROR","messagePattern":"PARAMETER_ERROR","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"warning","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/bot/impl/BotAIServiceImpl.java","lineNumber":289,"sourceCode":"\n            log.info(\"User [{}] avatar generated and uploaded successfully: {}\", uid, avatarUrl);\n            return avatarUrl;\n\n        } catch (BusinessException e) {\n            throw e;\n        } catch (Exception e) {\n            log.error(\"Exception occurred during AI avatar generation for user [{}]\", uid, e);\n            return \"Should return fallback content\";\n        } finally {\n            IoUtil.close(imageInput);\n            IoUtil.close(compressImageInput);\n        }\n    }\n\n    @Override\n    public BotGenerationDTO sentenceBot(String sentence, String uid) {\n        if (StringUtils.isBlank(sentence)) {\n            throw new BusinessException(PARAMETER_ERROR);\n        }\n\n        if (sentence.length() > 2000) {\n            log.error(\"One-sentence assistant generation input too long: length={}\", sentence.length());\n            throw new BusinessException(PARAMETER_ERROR);\n        }\n\n        try {\n            // Use AI service to generate assistant configuration\n            BotGenerationDTO botDetail = generateBotFromSentence(sentence);\n\n            // Generate AI avatar (optional, enable as needed)\n            String botName = botDetail.getBotName();\n            String botDesc = botDetail.getBotDesc();\n            if (StringUtils.isNotBlank(botName) && StringUtils.isNotBlank(botDesc)) {\n                try {\n                    String avatarUrl = generateAvatar(uid, botName, botDesc);\n                    if (StringUtils.isNotBlank(avatarUrl) && !avatarUrl.equals(\"Should return fallback content\")) {","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/bot/impl/BotAIServiceImpl.java#L271-L307","documentation":"BotAIServiceImpl.sentenceBot throws BusinessException(PARAMETER_ERROR) when the one-sentence assistant description is blank. This is a guard clause at the very top of the method: the AI generation flow cannot build a bot from an empty description, so the service rejects the call before spending any model tokens. It maps to the platform's PARAMETER_ERROR response enum, meaning the caller supplied invalid input, not that the backend failed.","triggerScenarios":"Calling sentenceBot(sentence, uid) with sentence == null, an empty string, or a whitespace-only string (StringUtils.isBlank). Any REST/controller path that forwards user-submitted one-sentence bot descriptions without server-side or client-side trimming/validation.","commonSituations":"Frontend submits a form with an untouched/empty description field; a script or API client sends an empty JSON field; whitespace-only input like '   ' sneaks past naive isEmpty checks; a bot copy/import pipeline passes an uninitialized description.","solutions":["Trim the sentence and validate it is non-blank before calling sentenceBot","Add @NotBlank on the request DTO field so bean validation rejects it earlier with a clearer message","Return a 400 with a field-specific error from the controller instead of relying on the service guard","Fix the client to disable the submit button until the description field has content"],"exampleFix":"// before\nservice.sentenceBot(request.getSentence(), uid);\n// after\nString sentence = StringUtils.trimToEmpty(request.getSentence());\nif (StringUtils.isBlank(sentence)) {\n    throw new BusinessException(ResponseEnum.PARAMETER_ERROR, \"sentence must not be blank\");\n}\nservice.sentenceBot(sentence, uid);","handlingStrategy":"validation","validationCode":"if (sentence == null || sentence.trim().isEmpty()) {\n    throw new IllegalArgumentException(\"sentence must not be blank\");\n}","typeGuard":"boolean isValidSentence(String s) { return s != null && !s.trim().isEmpty(); }","tryCatchPattern":"try {\n    dto = botAIService.sentenceBot(sentence, uid);\n} catch (BusinessException e) {\n    if (\"PARAMETER_ERROR\".equals(e.getCode())) {\n        return ResponseEntity.badRequest().body(Map.of(\"message\", \"sentence must be 1-2000 non-blank characters\"));\n    }\n    throw e;\n}","preventionTips":["Trim user input before sending","Use @NotBlank bean validation on DTOs","Disable submit until the description field is filled","Treat whitespace-only strings as empty"],"tags":["parameter-validation","java","blank-input"],"backgroundTag":"empty-required-field","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"}