{"record":{"id":"fb41d25bdccf22b6","repo":"iflytek/astron-agent","slug":"dev-id-must-been-more-than-zero","errorCode":null,"errorMessage":"dev_id must been more than zero","messagePattern":"dev_id must been more than zero","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/tenant/internal/handler/req.go","lineNumber":79,"sourceCode":"\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\"`\n\tAppDesc   string `json:\"app_desc\"`\n}\n","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/tenant/internal/handler/req.go#L61-L97","documentation":"newAddAppReq requires DevId to be a positive integer; a dev_id of zero or negative fails validation with this message. The dev id identifies the owning developer/tenant and must reference an existing positive id.","triggerScenarios":"POST add-app (SaveApp) with dev_id missing (0 zero-value), negative, or non-numeric input that binds to the zero value of the numeric field.","commonSituations":"Client not yet knowing its dev_id (uninitialized config); JSON field name mismatch causing zero binding; upstream code passing an unset int variable; tests with placeholder dev_id values.","solutions":["Send a positive integer dev_id in the request body","Ensure the dev_id is fetched/initialized before calling (check the client's tenant/dev context)","Verify the JSON key matches the struct binding tag so the value actually binds (non-numeric strings bind to 0)"],"exampleFix":"// before\n{\"request_id\":\"r1\",\"app_name\":\"myapp\",\"dev_id\":0,\"cloud_id\":\"c1\"}\n// after\n{\"request_id\":\"r1\",\"app_name\":\"myapp\",\"dev_id\":42,\"cloud_id\":\"c1\"}","handlingStrategy":"validation","validationCode":"if req.DevId <= 0 {\n    return errors.New(\"dev_id must be a positive integer\")\n}","typeGuard":null,"tryCatchPattern":"if err := submitAddApp(req); err != nil {\n    if strings.Contains(err.Error(), \"dev_id must been more than zero\") {\n        return fmt.Errorf(\"dev_id not set or invalid; initialize developer context first: %w\", err)\n    }\n    return err\n}","preventionTips":["Initialize the dev/tenant context before calling add-app","Guard against zero-value ints in payload builders (require explicit assignment)","Ensure JSON dev_id is numeric, not a string that binds to 0","Cover dev_id validation in integration tests"],"tags":["go","gin","api","validation","json"],"backgroundTag":"value-out-of-range","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"}