{"record":{"id":"e68f55d2ff22ea64","repo":"iflytek/astron-agent","slug":"workflow-query-length-outrange","errorCode":"WORKFLOW_QUERY_LENGTH_OUTRANGE","errorMessage":"WORKFLOW_QUERY_LENGTH_OUTRANGE","messagePattern":"WORKFLOW_QUERY_LENGTH_OUTRANGE","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"warning","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/WorkflowService.java","lineNumber":5750,"sourceCode":"            return name;\n        }\n\n        // If JSON serialization is needed, setter methods can be added\n        public void setName(String name) {\n            this.name = name;\n        }\n    }\n\n    public PageData<PromptTemplate> listPagePromptTemplate(Integer current, Integer pageSize, String search) {\n        // 1. Build query conditions\n        LambdaQueryWrapper<PromptTemplate> wrapper = Wrappers.lambdaQuery(PromptTemplate.class)\n                .eq(PromptTemplate::getDeleted, false)\n                .orderByDesc(PromptTemplate::getCreatedTime);\n\n        // 2. Handle search\n        if (search != null) {\n            if (search.length() > 30) {\n                throw new BusinessException(ResponseEnum.WORKFLOW_QUERY_LENGTH_OUTRANGE);\n            }\n            dealWithSearchPromptTemplate(search, wrapper);\n        }\n\n        // 3. Use MyBatis-Plus pagination query (efficient)\n        Page<PromptTemplate> page = new Page<>(current, pageSize);\n        Page<PromptTemplate> result = promptTemplateMapper.selectPage(page, wrapper);\n\n        for (PromptTemplate record : result.getRecords()) {\n            // {\"characterSettings\": \"characterSettings\", \"thinkStep\": \"thinkStep\", \"userQuery\": \"userQuery\"}\n            JSONObject json = JSON.parseObject(record.getPrompt());\n            record.setCharacterSettings(json.get(\"characterSettings\").toString());\n            record.setThinkStep(json.get(\"thinkStep\").toString());\n            record.setUserQuery(json.get(\"userQuery\").toString());\n            record.setJsonAdaptationModel(JSON.parseObject(record.getAdaptationModel()));\n            record.setInputs(extractInputs(record.getPrompt()));\n        }\n","sourceCodeStart":5732,"sourceCodeEnd":5768,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/WorkflowService.java#L5732-L5768","documentation":"Thrown by WorkflowService during paginated prompt-template queries when the search term exceeds the maximum allowed length of 30 characters. The service validates search length before applying it to the MyBatis-Plus query wrapper.","triggerScenarios":"Calling the prompt template list/search API with a search parameter whose string length is greater than 30, e.g. pasting a whole sentence or prompt text into the search box.","commonSituations":"Frontend search box lacking maxLength validation; user pasting long text as a search term; API consumers sending full prompt content instead of a short keyword.","solutions":["Shorten the search term to 30 characters or fewer before calling the API","Add client-side maxLength=30 on the search input to fail fast","Trim and validate the search string in the client before sending","If server behavior change is desired, raise the limit in WorkflowService (product decision)"],"exampleFix":"// before\nconst results = await api.searchPromptTemplates({ search: userInput });\n// after\nconst term = userInput.trim().slice(0, 30);\nconst results = await api.searchPromptTemplates({ search: term });","handlingStrategy":"validation","validationCode":"const term = searchInput.trim();\nif (term.length > 30) {\n  throw new Error(\"Search term must be 30 characters or fewer\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set maxLength=30 on search inputs","Trim user input before sending","Document the 30-char limit in the API contract/OpenAPI schema"],"tags":["validation","workflow","input-length"],"backgroundTag":"value-out-of-range","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"}