{"record":{"id":"ebfa7cef00327f0d","repo":"jackc/pgx","slug":"structargs-requires-a-struct-or-pointer-to-struct-ebfa7c","errorCode":null,"errorMessage":"StructArgs requires a struct or pointer to struct, got %s","messagePattern":"StructArgs requires a struct or pointer to struct, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"named_args.go","lineNumber":91,"sourceCode":"\nfunc structArgs(sa any) (map[string]any, error) {\n\tif sa == nil {\n\t\treturn nil, fmt.Errorf(\"StructArgs requires a struct or pointer to struct, got nil\")\n\t}\n\n\tv := reflect.ValueOf(sa)\n\tt := v.Type()\n\n\tif t.Kind() == reflect.Pointer {\n\t\tif v.IsNil() {\n\t\t\treturn nil, fmt.Errorf(\"StructArgs requires a non-nil pointer to struct\")\n\t\t}\n\t\tv = v.Elem()\n\t\tt = v.Type()\n\t}\n\n\tif t.Kind() != reflect.Struct {\n\t\treturn nil, fmt.Errorf(\"StructArgs requires a struct or pointer to struct, got %s\", t)\n\t}\n\n\tout := make(map[string]any, t.NumField())\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tsf := t.Field(i)\n\n\t\t// Ignore unexported fields.\n\t\tif sf.PkgPath != \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tkey, ok, err := dbTagKey(sf)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/named_args.go#L73-L109","documentation":"StructArgs was given a value that is neither a struct nor a pointer to a struct (kind reported via %s). Only struct values can be mapped to named arguments.","triggerScenarios":"Thrown at named_args.go:91 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a struct type whose exported fields map to the named parameters","Use NamedArgs with a map if the source data is not a struct"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ec1a0befd22592cffffdeeb0a50311b506372f4c","analyzedAt":"2026-08-04T22:52:11.263Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}