iflytek/astron-agent · warning
Invalid publish type format
Error message
Invalid publish type format: {} What it means
getPublishChannelCode converts the publishType string into a ReleaseTypeEnum code. It first tries to parse the input as a numeric code; on NumberFormatException it looks the value up by name, and if that also fails it logs a warning and silently defaults to ReleaseTypeEnum.MARKET's code. An unrecognized publishType therefore degrades to the MARKET channel rather than failing.
Solutions
- Update ReleaseTypeEnum to include the new/unknown channel value the client is sending
- Validate publishType at the API boundary (controller) against ReleaseTypeEnum.getByName/known codes and reject unknown values with 400
- Trim/normalize the input (case, whitespace) before matching
- If MARKET default is wrong for your use case, throw IllegalArgumentException instead of silently defaulting
Example fix
// before
log.warn("Invalid publish type format: {}", publishType);
return ReleaseTypeEnum.MARKET.getCode();
// after
log.error("Unknown publish type: {}", publishType);
throw new IllegalArgumentException("Unsupported publishType: " + publishType); Defensive patterns
Strategy: validation
Validate before calling
// validate publishType before calling publishWorkflow
ReleaseTypeEnum type = ReleaseTypeEnum.getByName(publishType);
if (type == null && publishType.chars().anyMatch(c -> !Character.isDigit(c))) {
throw new IllegalArgumentException("publishType must be a valid code or name: " + publishType);
} Type guard
boolean isValidPublishType(String s) {
if (s == null || s.isBlank()) return false;
try { Integer.parseInt(s.trim()); return true; }
catch (NumberFormatException e) { return ReleaseTypeEnum.getByName(s.trim()) != null; }
} Try / catch
try {
publish(publishType);
} catch (IllegalArgumentException e) {
throw new BadRequestException("Unsupported publishType: " + publishType
+ ", allowed: " + Arrays.toString(ReleaseTypeEnum.values()));
} Prevention
- Keep frontend release-channel options and ReleaseTypeEnum in sync (shared contract test)
- Trim and case-normalize publishType before matching
- Reject unknown publishTypes at the controller with 400 instead of silently defaulting to MARKET
- Write an enum coverage test iterating all frontend channel values against the backend enum
When it happens
Trigger: publishWorkflow passes publishType that is neither a valid integer code nor a known ReleaseTypeEnum name — e.g. a new channel added on the frontend before the backend enum was updated, or a stale/misspelled channel string from an API client.
Common situations: Frontend and backend enum drift after adding a release channel; clients sending localized/display names instead of enum names; copy-paste of channel value with different casing or whitespace; old clients sending removed channel names.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/2450f82e62a1c464.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/workflow/impl/WorkflowReleaseServiceImpl.java:336
versionId, auditResult, e);
return false;
}
}
/**
* Get publish channel code
*/
private Integer getPublishChannelCode(String publishType) {
try {
Integer typeCode = Integer.parseInt(publishType);
// Direct return since ReleaseTypeEnum code is the channel code
return typeCode;
} catch (NumberFormatException e) {
ReleaseTypeEnum releaseType = ReleaseTypeEnum.getByName(publishType);
if (releaseType != null) {
return releaseType.getCode();
}
log.warn("Invalid publish type format: {}", publishType);
return ReleaseTypeEnum.MARKET.getCode();
}
}
/**
* Get appId by botId from chat_bot_api table, fallback to configured maas appId
*/
private String getAppIdByBotId(Integer botId) {
try {
// Query chat_bot_api table to find appId for the given botId
LambdaQueryWrapper<ChatBotApi> queryWrapper = new LambdaQueryWrapper<ChatBotApi>()
.eq(ChatBotApi::getBotId, botId)
.last("LIMIT 1");
ChatBotApi chatBotApi = chatBotApiMapper.selectOne(queryWrapper);
if (chatBotApi != null && chatBotApi.getAppId() != null) {
log.debug("Found appId for botId {}: {}", botId, chatBotApi.getAppId());View on GitHub (pinned to 5e758547a8)