jackc/pgx · error

field has empty ` ` tag

Error message

field %s has empty `%s` tag

What it means

A struct field carries an explicitly present but empty `db:` tag (e.g. db:""). An empty tag is treated as a configuration error rather than falling back to the field name, since it likely indicates an unfinished edit.

Solutions

  1. Fill in the tag value or remove the empty tag entirely
  2. Use db:"-" if the field should be skipped
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at named_args.go:144 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of jackc/pgx@ec1a0befd2 (2026-08-04). Data as JSON: /api/errors/ca02637af00e69e1. Report an issue: GitHub.

Appendix: source

Thrown at named_args.go:144

		ft := sf.Type
		if ft.Kind() == reflect.Pointer {
			ft = ft.Elem()
		}
		if ft.Kind() == reflect.Struct {
			return "", false, nil
		}
	}

	dbTag, dbTagPresent := sf.Tag.Lookup(structTagKey)
	if dbTagPresent {
		dbTag, _, _ = strings.Cut(dbTag, ",")
	}
	if dbTag == "-" {
		return "", false, nil
	}
	if dbTagPresent {
		if dbTag == "" {
			return "", false, fmt.Errorf("field %s has empty `%s` tag", sf.Name, structTagKey)
		}
		return dbTag, true, nil
	}

	return sf.Name, true, nil
}

type namedArg string

type sqlLexer struct {
	src     string
	start   int
	pos     int
	nested  int // multiline comment nesting level.
	stateFn stateFn
	parts   []any

	nameToOrdinal map[namedArg]int

View on GitHub (pinned to ec1a0befd2)