flipped-aurora/gin-vue-admin · error

模块 %d 字段 %d 的 fieldSearchType '%s' 不支持

Error message

模块 %d 字段 %d 的 fieldSearchType '%s' 不支持

What it means

If a field declares fieldSearchType (the query condition generated for the list/search UI), it must be one of the supported operators: =, !=, >, >=, <, <=, LIKE, BETWEEN, NOT BETWEEN, IN, NOT IN. Empty means 'no search' and is allowed; anything non-empty and outside the list is rejected.

Source

Thrown at server/mcp/gva_execute.go:381

				if field.FieldType == "" {
					return fmt.Errorf("模块 %d 字段 %d 的 fieldType 不能为空", moduleIndex+1, i+1)
				}
				if field.FieldJson == "" {
					return fmt.Errorf("模块 %d 字段 %d 的 fieldJson 不能为空", moduleIndex+1, i+1)
				}
				if field.ColumnName == "" {
					return fmt.Errorf("模块 %d 字段 %d 的 columnName 不能为空", moduleIndex+1, i+1)
				}

				validFieldTypes := []string{"string", "int", "int64", "float64", "bool", "time.Time", "enum", "picture", "video", "file", "pictures", "array", "richtext", "json"}
				if !slices.Contains(validFieldTypes, field.FieldType) {
					return fmt.Errorf("模块 %d 字段 %d 的 fieldType '%s' 不支持", moduleIndex+1, i+1, field.FieldType)
				}

				if field.FieldSearchType != "" {
					validSearchTypes := []string{"=", "!=", ">", ">=", "<", "<=", "LIKE", "BETWEEN", "NOT BETWEEN", "IN", "NOT IN"}
					if !slices.Contains(validSearchTypes, field.FieldSearchType) {
						return fmt.Errorf("模块 %d 字段 %d 的 fieldSearchType '%s' 不支持", moduleIndex+1, i+1, field.FieldSearchType)
					}
				}

				if field.DataSource != nil {
					associationValue := field.DataSource.Association
					if associationValue == 2 && field.FieldType != "array" {
						logger.WithCtx(ctx).Mod("mcp").Info(fmt.Sprintf("module %d field %d association=2, force fieldType to array", moduleIndex+1, i+1))
						moduleInfo.Fields[i].FieldType = "array"
					}
					if associationValue != 1 && associationValue != 2 {
						return fmt.Errorf("模块 %d 字段 %d 的 dataSource.association 必须是 1 或 2", moduleIndex+1, i+1)
					}
				}
			}

			if !moduleInfo.GvaModel {
				primaryKeyCount := 0
				for _, field := range moduleInfo.Fields {

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Use exactly one of: =, !=, >, >=, <, <=, LIKE, BETWEEN, NOT BETWEEN, IN, NOT IN (case-sensitive)
  2. Remove fieldSearchType entirely if the field should not be searchable
  3. Normalize operator casing when generating plans (e.g. strings.ToUpper for keyword operators)

Example fix

// before
{"fieldJson":"name","fieldType":"string","columnName":"name","fieldSearchType":"like"}
// after
{"fieldJson":"name","fieldType":"string","columnName":"name","fieldSearchType":"LIKE"}
Defensive patterns

Strategy: validation

Validate before calling

var validSearchTypes = []string{"=","!=",">",">=","<","<=","LIKE","BETWEEN","NOT BETWEEN","IN","NOT IN"}
if f.FieldSearchType != "" && !slices.Contains(validSearchTypes, f.FieldSearchType) { return fmt.Errorf("bad searchType %q", f.FieldSearchType) }

Type guard

func isSupportedSearchType(s string) bool {
  return s == "" || slices.Contains([]string{"=","!=",">",">=","<","<=","LIKE","BETWEEN","NOT BETWEEN","IN","NOT IN"}, s)
}

Prevention

When it happens

Trigger: Plan field has fieldSearchType set to a value like 'like' (wrong case), '~', 'REGEXP', 'contains', or a misspelled operator.

Common situations: LLM emits lowercase 'like'/'in' instead of 'LIKE'/'IN'; copy-paste from another framework's query operators; hand-written plan using free-text condition names.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31). Data as JSON: /api/errors/45fae03b2f9b7545. Report an issue: GitHub.