{"record":{"id":"6d8a49219c0cec9a","repo":"iflytek/astron-agent","slug":"param-error-6d8a49","errorCode":"PARAM_ERROR","errorMessage":"PARAM_ERROR","messagePattern":"PARAM_ERROR","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/WorkflowArtifactFileValidator.java","lineNumber":452,"sourceCode":"                }\n            }\n        }\n        return false;\n    }\n\n    private String normalizeFileName(String originalFileName) {\n        String normalized = StringUtils.defaultString(originalFileName).replace('\\\\', '/');\n        int slash = normalized.lastIndexOf('/');\n        if (slash >= 0) {\n            normalized = normalized.substring(slash + 1);\n        }\n        normalized = normalized\n                .replaceAll(\"[\\\\p{Cntrl}\\\\\\\\/:*?\\\"<>|]+\", \"_\")\n                .replaceAll(\"\\\\.{2,}\", \".\")\n                .replaceAll(\"^\\\\.+\", \"\")\n                .trim();\n        if (StringUtils.isBlank(normalized) || normalized.length() > MAX_FILE_NAME_LENGTH) {\n            throw new BusinessException(ResponseEnum.PARAM_ERROR);\n        }\n        return normalized;\n    }\n\n    private String normalizeMediaType(String contentType) {\n        String normalized = StringUtils.lowerCase(StringUtils.trimToEmpty(contentType), Locale.ROOT);\n        int separator = normalized.indexOf(';');\n        return separator < 0 ? normalized : normalized.substring(0, separator).trim();\n    }\n\n    public record ValidatedArtifact(String fileName, String contentType) {}\n\n    record OoxmlResourceLimits(\n            int maxEntryCount,\n            long maxEntryBytes,\n            long maxXmlEntryBytes,\n            long maxControlXmlEntryBytes,\n            long maxTotalExpandedBytes) {","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/WorkflowArtifactFileValidator.java#L434-L470","documentation":"normalizeFileName throws PARAM_ERROR when the sanitized artifact file name is blank or exceeds MAX_FILE_NAME_LENGTH. The name is lower-impact sanitized (control characters, path metacharacters, repeated dots become underscores/single dots); if nothing usable remains, or it is still too long, the upload request is rejected as an invalid parameter. It protects the object-store key and DB record from unusable names.","triggerScenarios":"Uploading a workflow artifact whose fileName contains only forbidden characters (e.g. \"???\", \"///\") so it normalizes to blank, or whose name is longer than MAX_FILE_NAME_LENGTH after sanitization.","commonSituations":"Programmatic uploads passing empty or placeholder file names; browser uploads with path-only names; generated files whose names were never truncated before sending.","solutions":["Supply a non-empty file name consisting of allowed characters when calling the artifact upload API","Truncate the file name client-side to MAX_FILE_NAME_LENGTH (keeping the extension) before uploading","Avoid control characters and \\\\ / : * ? \" < > | in file names","Ensure the multipart part actually carries a filename (some HTTP clients omit it)"],"exampleFix":"// before\nuploadArtifact(workflowId, file, \"a:\".repeat(500)); // PARAM_ERROR\n// after\nString safe = StringUtils.abbreviate(name, MAX_FILE_NAME_LENGTH)\n        .replaceAll(\"[\\\\p{Cntrl}\\\\\\\\/:*?\\\"<>|+]\", \"_\");\nuploadArtifact(workflowId, file, safe);","handlingStrategy":"validation","validationCode":"// Mirror the server's normalization before upload\nString safe = Optional.ofNullable(fileName).orElse(\"\")\n        .replaceAll(\"[\\\\p{Cntrl}\\\\\\\\/:*?\\\"<>|]+\", \"_\")\n        .replaceAll(\"\\\\.{2,}\", \".\")\n        .replaceAll(\"^\\\\.+\", \"\")\n        .trim();\nif (safe.isEmpty() || safe.length() > 255)\n    throw new IllegalArgumentException(\"Invalid artifact file name: \" + fileName);","typeGuard":"boolean isValidFileName(String name) {\n    if (name == null) return false;\n    String s = name.replaceAll(\"[\\\\p{Cntrl}\\\\\\\\/:*?\\\"<>|]+\", \"_\").trim();\n    return !s.isEmpty() && s.length() <= 255;\n}","tryCatchPattern":"try {\n    artifactApi.upload(workflowId, file, fileName);\n} catch (BusinessException e) {\n    if (\"PARAM_ERROR\".equals(e.getCode())) {\n        throw new ClientInputException(\"File name blank or too long: \" + fileName, e);\n    }\n    throw e;\n}","preventionTips":["Sanitize and truncate file names client-side before every upload","Always set the multipart filename explicitly in your HTTP client","Keep names well under the server's MAX_FILE_NAME_LENGTH to allow for sanitization"],"tags":["java","validation","filename","workflow-artifact"],"backgroundTag":"invalid-argument-format","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"}