iflytek/astron-agent · error

app_name must not been empty

Error message

app_name must not been empty

What it means

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.

Solutions

  1. Include a non-empty app_name in the request JSON body
  2. Fix form validation on the client to require the name field before submit
  3. Confirm the JSON key matches the AddAppReq binding tag (e.g. "app_name")

Example fix

// before
{"request_id":"r1","dev_id":3,"cloud_id":"c1"}
// after
{"request_id":"r1","app_name":"myapp","dev_id":3,"cloud_id":"c1"}
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(req.AppName) == "" {
    return errors.New("app_name is required")
}

Try / catch

if err := submitAddApp(req); err != nil {
    if strings.Contains(err.Error(), "app_name must not been empty") {
        return fmt.Errorf("please provide an app name before creating the app: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/b123deea57bb1035. Report an issue: GitHub.

Appendix: source

Thrown at core/tenant/internal/handler/req.go:76

type AddAppReq struct {
	RequestId string `json:"request_id"`
	AppName   string `json:"app_name"`
	AppDesc   string `json:"app_desc"`
	DevId     int64  `json:"dev_id"`
	CloudId   string `json:"cloud_id"`
}

func newAddAppReq(c *gin.Context) (*AddAppReq, error) {
	req := &AddAppReq{}
	err := c.BindJSON(req)
	if err != nil {
		return nil, err
	}
	if len(req.RequestId) == 0 {
		return nil, errors.New("request_id must not been empty")
	}
	if len(req.AppName) == 0 {
		return nil, errors.New("app_name must not been empty")
	}
	if req.DevId <= 0 {
		return nil, errors.New("dev_id must been more than zero")
	}
	if len(req.CloudId) == 0 {
		return nil, errors.New("cloud_id must not been empty")
	}
	if len(req.AppDesc) == 0 {
		req.AppDesc = ""
	}
	return req, nil
}

type ModifyAppReq struct {
	RequestId string `json:"request_id"`
	AppId     string `json:"app_id"`
	AppName   string `json:"app_name"`
	CloudId   string `json:"cloud_id"`

View on GitHub (pinned to 5e758547a8)