{"record":{"id":"2450f82e62a1c464","repo":"iflytek/astron-agent","slug":"invalid-publish-type-format","errorCode":null,"errorMessage":"Invalid publish type format: {}","messagePattern":"Invalid publish type format: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/workflow/impl/WorkflowReleaseServiceImpl.java","lineNumber":336,"sourceCode":"                    versionId, auditResult, e);\n            return false;\n        }\n    }\n\n    /**\n     * Get publish channel code\n     */\n    private Integer getPublishChannelCode(String publishType) {\n        try {\n            Integer typeCode = Integer.parseInt(publishType);\n            // Direct return since ReleaseTypeEnum code is the channel code\n            return typeCode;\n        } catch (NumberFormatException e) {\n            ReleaseTypeEnum releaseType = ReleaseTypeEnum.getByName(publishType);\n            if (releaseType != null) {\n                return releaseType.getCode();\n            }\n            log.warn(\"Invalid publish type format: {}\", publishType);\n            return ReleaseTypeEnum.MARKET.getCode();\n        }\n    }\n\n    /**\n     * Get appId by botId from chat_bot_api table, fallback to configured maas appId\n     */\n    private String getAppIdByBotId(Integer botId) {\n        try {\n            // Query chat_bot_api table to find appId for the given botId\n            LambdaQueryWrapper<ChatBotApi> queryWrapper = new LambdaQueryWrapper<ChatBotApi>()\n                    .eq(ChatBotApi::getBotId, botId)\n                    .last(\"LIMIT 1\");\n\n            ChatBotApi chatBotApi = chatBotApiMapper.selectOne(queryWrapper);\n\n            if (chatBotApi != null && chatBotApi.getAppId() != null) {\n                log.debug(\"Found appId for botId {}: {}\", botId, chatBotApi.getAppId());","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/workflow/impl/WorkflowReleaseServiceImpl.java#L318-L354","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nlog.warn(\"Invalid publish type format: {}\", publishType);\nreturn ReleaseTypeEnum.MARKET.getCode();\n// after\nlog.error(\"Unknown publish type: {}\", publishType);\nthrow new IllegalArgumentException(\"Unsupported publishType: \" + publishType);","handlingStrategy":"validation","validationCode":"// validate publishType before calling publishWorkflow\nReleaseTypeEnum type = ReleaseTypeEnum.getByName(publishType);\nif (type == null && publishType.chars().anyMatch(c -> !Character.isDigit(c))) {\n    throw new IllegalArgumentException(\"publishType must be a valid code or name: \" + publishType);\n}","typeGuard":"boolean isValidPublishType(String s) {\n    if (s == null || s.isBlank()) return false;\n    try { Integer.parseInt(s.trim()); return true; }\n    catch (NumberFormatException e) { return ReleaseTypeEnum.getByName(s.trim()) != null; }\n}","tryCatchPattern":"try {\n    publish(publishType);\n} catch (IllegalArgumentException e) {\n    throw new BadRequestException(\"Unsupported publishType: \" + publishType\n        + \", allowed: \" + Arrays.toString(ReleaseTypeEnum.values()));\n}","preventionTips":["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"],"tags":["java","enum","validation","publish"],"backgroundTag":"invalid-enum-value","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"}