{"id":"f7a512782fecf04e","repo":"docker/cli","slug":"expected-a-pointer-to-a-struct-got-a-pointer-to","errorCode":null,"errorMessage":"expected a pointer to a struct, got a pointer to %v","messagePattern":"expected a pointer to a struct, got a pointer to (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/formatter/reflect.go","lineNumber":35,"sourceCode":"\tm, err := marshalMap(x)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn json.Marshal(m)\n}\n\n// marshalMap marshals x to map[string]any\nfunc marshalMap(x any) (map[string]any, error) {\n\tval := reflect.ValueOf(x)\n\tif val.Kind() != reflect.Pointer {\n\t\treturn nil, fmt.Errorf(\"expected a pointer to a struct, got %v\", val.Kind())\n\t}\n\tif val.IsNil() {\n\t\treturn nil, errors.New(\"expected a pointer to a struct, got nil pointer\")\n\t}\n\tvalElem := val.Elem()\n\tif valElem.Kind() != reflect.Struct {\n\t\treturn nil, fmt.Errorf(\"expected a pointer to a struct, got a pointer to %v\", valElem.Kind())\n\t}\n\ttyp := val.Type()\n\tm := make(map[string]any)\n\tfor i := 0; i < val.NumMethod(); i++ {\n\t\tk, v, err := marshalForMethod(typ.Method(i), val.Method(i))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif k != \"\" {\n\t\t\tm[k] = v\n\t\t}\n\t}\n\treturn m, nil\n}\n\nvar unmarshallableNames = map[string]struct{}{\"FullHeader\": {}}\n\n// marshalForMethod returns the map key and the map value for marshalling the method.","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/formatter/reflect.go#L17-L53","documentation":"Error \"expected a pointer to a struct, got a pointer to %v\" thrown in docker/cli.","triggerScenarios":"Thrown at cli/command/formatter/reflect.go:35 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":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}