iflytek/astron-agent · error · BusinessException
PARAM_ERROR
PARAM_ERROR
Error message
PARAM_ERROR
What it means
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.
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)
Example fix
// before
uploadArtifact(workflowId, file, "a:".repeat(500)); // PARAM_ERROR
// after
String safe = StringUtils.abbreviate(name, MAX_FILE_NAME_LENGTH)
.replaceAll("[\\p{Cntrl}\\\\/:*?\"<>|+]", "_");
uploadArtifact(workflowId, file, safe); Defensive patterns
Strategy: validation
Validate before calling
// Mirror the server's normalization before upload
String safe = Optional.ofNullable(fileName).orElse("")
.replaceAll("[\\p{Cntrl}\\\\/:*?\"<>|]+", "_")
.replaceAll("\\.{2,}", ".")
.replaceAll("^\\.+", "")
.trim();
if (safe.isEmpty() || safe.length() > 255)
throw new IllegalArgumentException("Invalid artifact file name: " + fileName); Type guard
boolean isValidFileName(String name) {
if (name == null) return false;
String s = name.replaceAll("[\\p{Cntrl}\\\\/:*?\"<>|]+", "_").trim();
return !s.isEmpty() && s.length() <= 255;
} Try / catch
try {
artifactApi.upload(workflowId, file, fileName);
} catch (BusinessException e) {
if ("PARAM_ERROR".equals(e.getCode())) {
throw new ClientInputException("File name blank or too long: " + fileName, e);
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Programmatic uploads passing empty or placeholder file names; browser uploads with path-only names; generated files whose names were never truncated before sending.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/6d8a49219c0cec9a.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/WorkflowArtifactFileValidator.java:452
}
}
}
return false;
}
private String normalizeFileName(String originalFileName) {
String normalized = StringUtils.defaultString(originalFileName).replace('\\', '/');
int slash = normalized.lastIndexOf('/');
if (slash >= 0) {
normalized = normalized.substring(slash + 1);
}
normalized = normalized
.replaceAll("[\\p{Cntrl}\\\\/:*?\"<>|]+", "_")
.replaceAll("\\.{2,}", ".")
.replaceAll("^\\.+", "")
.trim();
if (StringUtils.isBlank(normalized) || normalized.length() > MAX_FILE_NAME_LENGTH) {
throw new BusinessException(ResponseEnum.PARAM_ERROR);
}
return normalized;
}
private String normalizeMediaType(String contentType) {
String normalized = StringUtils.lowerCase(StringUtils.trimToEmpty(contentType), Locale.ROOT);
int separator = normalized.indexOf(';');
return separator < 0 ? normalized : normalized.substring(0, separator).trim();
}
public record ValidatedArtifact(String fileName, String contentType) {}
record OoxmlResourceLimits(
int maxEntryCount,
long maxEntryBytes,
long maxXmlEntryBytes,
long maxControlXmlEntryBytes,
long maxTotalExpandedBytes) {View on GitHub (pinned to 5e758547a8)