iflytek/astron-agent · error

app_id must not been empty

Error message

app_id must not been empty

What it means

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.

Solutions

  1. Include the existing app's id in the body as "app_id": "<app id>"
  2. Ensure the key is exactly app_id (snake_case) per the struct tag
  3. Set ModifyAppReq.AppId programmatically before serializing
  4. Confirm the app exists by listing apps if unsure of the id value

Example fix

// before
req := &ModifyAppReq{RequestId: id, Name: "new-name"}
// after
req := &ModifyAppReq{RequestId: id, AppId: "app-123", Name: "new-name"}
Defensive patterns

Strategy: validation

Validate before calling

if req.AppId == "" { return errors.New("app_id is required for ModifyApp") }

Type guard

func hasAppID(req *ModifyAppReq) bool { return req != nil && req.AppId != "" }

Try / catch

resp, err := client.ModifyApp(req)
if err != nil && strings.Contains(err.Error(), "app_id must not been empty") {
  // surface a config/input error to the caller, do not retry
}

Prevention

When it happens

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

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

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/0378ce93113835fb. Report an issue: GitHub.

Appendix: source

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

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

func newModifyAppReq(c *gin.Context) (*ModifyAppReq, error) {
	req := &ModifyAppReq{}
	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.AppId) == 0 {
		return nil, errors.New("app_id must not been empty")
	}
	return req, nil
}

type DisableAppReq struct {
	RequestId string `json:"request_id"`
	AppId     string `json:"app_id"`
	Disable   bool   `json:"disable"`
}

func newDisableAppReq(c *gin.Context) (*DisableAppReq, error) {
	req := &DisableAppReq{}
	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")

View on GitHub (pinned to 5e758547a8)