{"record":{"id":"600d49084c5dafe1","repo":"larksuite/cli","slug":"s-field-s-json-tag-must-explicitly-name-the-fiel","errorCode":null,"errorMessage":"%s field %s json tag must explicitly name the field","messagePattern":"(.+?) field (.+?) json tag must explicitly name the field","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_data.go","lineNumber":211,"sourceCode":"\n\tshape := typedObjectShape{}\n\tseen := make(map[string]string)\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tfield := t.Field(i)\n\t\tif !field.IsExported() {\n\t\t\tcontinue\n\t\t}\n\t\trawJSON, ok := field.Tag.Lookup(\"json\")\n\t\tif !ok {\n\t\t\treturn typedObjectShape{}, fmt.Errorf(\"%s field %s must declare json tag\", path, field.Name)\n\t\t}\n\t\tparts := strings.Split(rawJSON, \",\")\n\t\tname := parts[0]\n\t\tif name == \"-\" {\n\t\t\tcontinue\n\t\t}\n\t\tif name == \"\" {\n\t\t\treturn typedObjectShape{}, fmt.Errorf(\"%s field %s json tag must explicitly name the field\", path, field.Name)\n\t\t}\n\t\tomitempty := false\n\t\tfor _, option := range parts[1:] {\n\t\t\tswitch option {\n\t\t\tcase \"omitempty\":\n\t\t\t\tomitempty = true\n\t\t\tcase \"\":\n\t\t\tdefault:\n\t\t\t\treturn typedObjectShape{}, fmt.Errorf(\"%s field %s has unsupported json option %q\", path, field.Name, option)\n\t\t\t}\n\t\t}\n\t\tif previous, exists := seen[name]; exists {\n\t\t\treturn typedObjectShape{}, fmt.Errorf(\"%s field %s JSON name %q duplicates field %s\", path, field.Name, name, previous)\n\t\t}\n\t\tseen[name] = field.Name\n\t\tschema, err := parseSchemaTag(field.Tag.Get(\"schema\"), field.Type, input)\n\t\tif err != nil {\n\t\t\treturn typedObjectShape{}, fmt.Errorf(\"%s field %s (%s): %w\", path, field.Name, name, err)","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_data.go#L193-L229","documentation":"The compiler found a `json` tag whose name portion is empty, e.g. `json:\",omitempty\"`. The library requires each field to explicitly name itself in the tag so wire names are stable and searchable; Go's default fallback to the field name is not accepted. This keeps compiled schemas deterministic and independent of Go identifier casing rules.","triggerScenarios":"A struct field tagged like `json:\",omitempty\"` or `json:\",string\"` processed by compileStructShape (via compileData or shapeForType).","commonSituations":"Retrofitting omitempty onto an existing field by prepending a comma and forgetting the name; mechanically adding `json:\"...\"` tags via tooling that leaves the name blank; intent to rely on Go's default naming, which this compiler forbids.","solutions":["Write the wire name explicitly before the comma, e.g. `json:\"user_id,omitempty\"`","Use `json:\"-\"` if the field must be excluded from the compiled shape"],"exampleFix":"// before\nOptional string `json:\",omitempty\"`\n// after\nOptional string `json:\"optional,omitempty\"`","handlingStrategy":"validation","validationCode":"for i := 0; i < t.NumField(); i++ {\n    f := t.Field(i)\n    tag, ok := f.Tag.Lookup(\"json\")\n    if ok && strings.Split(tag, \",\")[0] == \"\" {\n        return fmt.Errorf(\"field %s must name itself in the json tag\", f.Name)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never write json tags starting with a comma","Always copy the full tag `json:\"name,opts\"` including the name","Review diffs for mechanical tag edits that drop names"],"tags":["go","struct-tags","json","schema-compile"],"backgroundTag":"missing-json-struct-tag","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}