{"record":{"id":"c1d11ed85ce512fa","repo":"iflytek/astron-agent","slug":"cloud-id-must-not-been-empty","errorCode":null,"errorMessage":"cloud_id must not been empty","messagePattern":"cloud_id must not been empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/tenant/internal/handler/req.go","lineNumber":82,"sourceCode":"}\n\nfunc newAddAppReq(c *gin.Context) (*AddAppReq, error) {\n\treq := &AddAppReq{}\n\terr := c.BindJSON(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(req.RequestId) == 0 {\n\t\treturn nil, errors.New(\"request_id must not been empty\")\n\t}\n\tif len(req.AppName) == 0 {\n\t\treturn nil, errors.New(\"app_name must not been empty\")\n\t}\n\tif req.DevId <= 0 {\n\t\treturn nil, errors.New(\"dev_id must been more than zero\")\n\t}\n\tif len(req.CloudId) == 0 {\n\t\treturn nil, errors.New(\"cloud_id must not been empty\")\n\t}\n\tif len(req.AppDesc) == 0 {\n\t\treq.AppDesc = \"\"\n\t}\n\treturn req, nil\n}\n\ntype ModifyAppReq struct {\n\tRequestId string `json:\"request_id\"`\n\tAppId     string `json:\"app_id\"`\n\tAppName   string `json:\"app_name\"`\n\tCloudId   string `json:\"cloud_id\"`\n\tAppDesc   string `json:\"app_desc\"`\n}\n\nfunc newModifyAppReq(c *gin.Context) (*ModifyAppReq, error) {\n\treq := &ModifyAppReq{}\n\terr := c.BindJSON(req)","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/tenant/internal/handler/req.go#L64-L100","documentation":"newAddAppReq requires a non-empty CloudId; an add-app request without cloud_id fails validation. The cloud id determines the cloud environment the app is registered in and must be provided by the caller.","triggerScenarios":"POST add-app (SaveApp) with JSON body missing cloud_id, empty string, or a key case mismatch with the binding tag so it binds to empty.","commonSituations":"Multi-cloud clients with cloud selection not yet performed in the UI; scripts with hardcoded payloads missing the newer cloud_id field added in an API revision; environment-specific config omitting the default cloud id.","solutions":["Include a non-empty cloud_id in the request JSON body","Set the default/selected cloud environment in the client before calling add-app","Verify the JSON key matches the AddAppReq binding tag (e.g. \"cloud_id\")"],"exampleFix":"// before\n{\"request_id\":\"r1\",\"app_name\":\"myapp\",\"dev_id\":42}\n// after\n{\"request_id\":\"r1\",\"app_name\":\"myapp\",\"dev_id\":42,\"cloud_id\":\"cloud-01\"}","handlingStrategy":"validation","validationCode":"if req.CloudId == \"\" {\n    return errors.New(\"cloud_id is required\")\n}","typeGuard":null,"tryCatchPattern":"if err := submitAddApp(req); err != nil {\n    if strings.Contains(err.Error(), \"cloud_id must not been empty\") {\n        return fmt.Errorf(\"select a cloud environment before creating the app: %w\", err)\n    }\n    return err\n}","preventionTips":["Resolve the target cloud environment before calling add-app","Configure a default cloud_id in client settings for single-cloud deployments","Keep payload field names aligned with server binding tags after API revisions","Validate all required fields (request_id, app_name, dev_id, cloud_id) in one client-side pre-check"],"tags":["go","gin","api","validation","json"],"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-19T12:17:13.211Z"}