{"record":{"id":"0378ce93113835fb","repo":"iflytek/astron-agent","slug":"app-id-must-not-been-empty","errorCode":null,"errorMessage":"app_id must not been empty","messagePattern":"app_id must not been empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/tenant/internal/handler/req.go","lineNumber":108,"sourceCode":"type 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)\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.AppId) == 0 {\n\t\treturn nil, errors.New(\"app_id must not been empty\")\n\t}\n\treturn req, nil\n}\n\ntype DisableAppReq struct {\n\tRequestId string `json:\"request_id\"`\n\tAppId     string `json:\"app_id\"`\n\tDisable   bool   `json:\"disable\"`\n}\n\nfunc newDisableAppReq(c *gin.Context) (*DisableAppReq, error) {\n\treq := &DisableAppReq{}\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\")","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/tenant/internal/handler/req.go#L90-L126","documentation":"newModifyAppReq rejects the request when AppId is empty (req.go:108). After binding the JSON body and validating request_id, the handler requires app_id to identify which application to modify; without it no target app exists and the call is rejected before any lookup.","triggerScenarios":"Calling ModifyApp with a body missing \"app_id\", sending \"app_id\": \"\", or using a key that does not map to the AppId field of ModifyAppReq.","commonSituations":"Copy-pasted payloads for create/modify where app_id was only introduced later; generated clients that leave optional-looking fields empty; renaming apps by payload built from a template missing the id field.","solutions":["Include the existing app's id in the body as \"app_id\": \"<app id>\"","Ensure the key is exactly app_id (snake_case) per the struct tag","Set ModifyAppReq.AppId programmatically before serializing","Confirm the app exists by listing apps if unsure of the id value"],"exampleFix":"// before\nreq := &ModifyAppReq{RequestId: id, Name: \"new-name\"}\n// after\nreq := &ModifyAppReq{RequestId: id, AppId: \"app-123\", Name: \"new-name\"}","handlingStrategy":"validation","validationCode":"if req.AppId == \"\" { return errors.New(\"app_id is required for ModifyApp\") }","typeGuard":"func hasAppID(req *ModifyAppReq) bool { return req != nil && req.AppId != \"\" }","tryCatchPattern":"resp, err := client.ModifyApp(req)\nif err != nil && strings.Contains(err.Error(), \"app_id must not been empty\") {\n  // surface a config/input error to the caller, do not retry\n}","preventionTips":["Fetch the app id from the list/detail API before modifying","Never send payloads built from templates without verifying app_id","Treat empty app ids in batch jobs as a skip-and-log condition"],"tags":["go","http-handler","validation","missing-field"],"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"}