{"record":{"id":"b123deea57bb1035","repo":"iflytek/astron-agent","slug":"app-name-must-not-been-empty","errorCode":null,"errorMessage":"app_name must not been empty","messagePattern":"app_name must not been empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/tenant/internal/handler/req.go","lineNumber":76,"sourceCode":"type AddAppReq struct {\n\tRequestId string `json:\"request_id\"`\n\tAppName   string `json:\"app_name\"`\n\tAppDesc   string `json:\"app_desc\"`\n\tDevId     int64  `json:\"dev_id\"`\n\tCloudId   string `json:\"cloud_id\"`\n}\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\"`","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/tenant/internal/handler/req.go#L58-L94","documentation":"newAddAppReq validates the AddApp JSON body in the tenant Go service; when app_name is an empty string it returns this error, which the SaveApp handler surfaces as a bad-request. It is a plain request-field guard before any persistence.","triggerScenarios":"POST add-app (SaveApp) with JSON body missing the app_name field, containing \"\", or with the field name cased differently from the binding tag so it binds to empty.","commonSituations":"Frontend submitting the creation form before the name field is filled; automated scripts building payloads without app_name; struct tag/field renames breaking client payloads after an API change.","solutions":["Include a non-empty app_name in the request JSON body","Fix form validation on the client to require the name field before submit","Confirm the JSON key matches the AddAppReq binding tag (e.g. \"app_name\")"],"exampleFix":"// before\n{\"request_id\":\"r1\",\"dev_id\":3,\"cloud_id\":\"c1\"}\n// after\n{\"request_id\":\"r1\",\"app_name\":\"myapp\",\"dev_id\":3,\"cloud_id\":\"c1\"}","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(req.AppName) == \"\" {\n    return errors.New(\"app_name is required\")\n}","typeGuard":null,"tryCatchPattern":"if err := submitAddApp(req); err != nil {\n    if strings.Contains(err.Error(), \"app_name must not been empty\") {\n        return fmt.Errorf(\"please provide an app name before creating the app: %w\", err)\n    }\n    return err\n}","preventionTips":["Require the app name in the creation form before enabling submit","Trim and check app_name client-side before sending","Keep payload builders and server binding tags in sync","Add contract tests covering all required add-app fields"],"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"}