{"record":{"id":"693bde37cd42fb8c","repo":"iflytek/astron-agent","slug":"appid-cannot-empty","errorCode":"APPID_CANNOT_EMPTY","errorMessage":"APPID_CANNOT_EMPTY","messagePattern":"APPID_CANNOT_EMPTY","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/WorkflowService.java","lineNumber":5057,"sourceCode":"            }\n            config.setCustomize(customize);\n            config.setCreateTime(new Date());\n            config.setUpdateTime(new Date());\n            mcpToolConfigMapper.updateById(config);\n        }\n    }\n\n\n    public Object replaceAppId(String appId, String flowId) {\n        log.info(\"replace appid for flowId={}\", flowId);\n        Workflow workflow = requireOwnedWorkflow(flowId);\n        replaceAppIdAfterAuthorization(appId, workflow);\n        return ApiResult.success(true);\n    }\n\n    private void replaceAppIdAfterAuthorization(String appId, Workflow workflow) {\n        if (StringUtils.isBlank(appId)) {\n            throw new BusinessException(ResponseEnum.APPID_CANNOT_EMPTY);\n        }\n        if (workflow == null\n                || workflow.getId() == null\n                || Boolean.TRUE.equals(workflow.getDeleted())) {\n            throw new BusinessException(ResponseEnum.WORKFLOW_NOT_EXIST);\n        }\n        String oldAppId = workflow.getAppId();\n        if (StringUtils.isNotBlank(oldAppId)) {\n            if (StringUtils.isNotBlank(workflow.getData())) {\n                workflow.setData(workflow.getData().replace(oldAppId, appId));\n            }\n            if (StringUtils.isNotBlank(workflow.getPublishedData())) {\n                workflow.setPublishedData(workflow.getPublishedData().replace(oldAppId, appId));\n            }\n        }\n        workflow.setAppId(appId);\n        workflow.setUpdateTime(new Date());\n        if (workflowMapper.updateById(workflow) != 1) {","sourceCodeStart":5039,"sourceCodeEnd":5075,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/WorkflowService.java#L5039-L5075","documentation":"APPID_CANNOT_EMPTY is thrown by the private replaceAppIdAfterAuthorization method when the appId argument passed for re-binding an authorized workflow's app id is null or blank. The method rewrites the old appId embedded in the workflow's data/publishedData JSON and the entity's appId column, and refuses to proceed without a target appId.","triggerScenarios":"Calling the authorization flow (the public method that delegates to replaceAppIdAfterAuthorization) with an empty/blank appId — e.g. the upstream authorization response contained no app id, a config field was not filled, or the caller passed an uninitialized variable.","commonSituations":"OAuth/authorization callbacks where the platform did not return an appId; forms where the appId field was left blank; environment misconfiguration where app credentials were never provisioned; older clients omitting the appId request parameter.","solutions":["Ensure the caller supplies a non-blank appId before invoking the authorization/replace endpoint.","Verify the authorization step completed and actually produced an appId; re-run authorization if not.","Add request-level @NotBlank validation on the appId parameter so the failure surfaces as a 400 with a clear message.","Check environment/config for missing app credentials if appId is expected to come from configuration."],"exampleFix":"// before\nworkflowService.replaceAppIdAfterAuthorization(\"\", workflow); // throws APPID_CANNOT_EMPTY\n// after\nif (StringUtils.isBlank(appId)) {\n    throw new IllegalArgumentException(\"appId is required to bind the workflow\");\n}\nworkflowService.replaceAppIdAfterAuthorization(appId, workflow);","handlingStrategy":"validation","validationCode":"if (appId == null || appId.isBlank()) {\n    throw new IllegalArgumentException(\"appId must be provided to bind the workflow\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    workflowService.authorizeAndReplaceAppId(appId, flowId);\n} catch (BusinessException e) {\n    if (\"APPID_CANNOT_EMPTY\".equals(e.getCode())) {\n        return ApiResult.badRequest(\"appId is required\");\n    }\n    throw e;\n}","preventionTips":["Annotate appId request params with @NotBlank for 400-level validation.","Verify authorization callbacks always deliver an appId before calling replace.","Provision app credentials per environment and fail config load if missing.","Log the authorization response keys to catch platforms that omit appId."],"tags":["workflow","appid","validation","java"],"backgroundTag":"empty-required-field","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"}