{"id":"b181fe997f4864e5","repo":"jackc/pgx","slug":"structargs-requires-a-non-nil-pointer-to-struct","errorCode":null,"errorMessage":"StructArgs requires a non-nil pointer to struct","messagePattern":"StructArgs requires a non-nil pointer to struct","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"named_args.go","lineNumber":84,"sourceCode":"func StrictStructArgs(sa any) QueryRewriter {\n\targs, err := structArgs(sa)\n\tif err != nil {\n\t\treturn errorQueryRewriter{err: err}\n\t}\n\treturn StrictNamedArgs(args)\n}\n\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","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/named_args.go#L66-L102","documentation":"Error \"StructArgs requires a non-nil pointer to struct\" thrown in jackc/pgx.","triggerScenarios":"Thrown at named_args.go:84 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"ec1a0befd22592cffffdeeb0a50311b506372f4c","analyzedAt":"2026-08-04T22:52:11.263Z","schemaVersion":2}