{"record":{"id":"bc8f80336d2307b3","repo":"jackc/pgx","slug":"scan-target-type-changed","errorCode":null,"errorMessage":"scan target type changed","messagePattern":"scan target type changed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/pgtype.go","lineNumber":1171,"sourceCode":"\t\t\t\tcodec = ByteaCodec{}\n\t\t\t}\n\t\t}\n\t\treturn &pointerEmptyInterfaceScanPlan{codec: codec, m: m, oid: oid, formatCode: formatCode}\n\t}\n\n\treturn &scanPlanFail{m: m, oid: oid, formatCode: formatCode}\n}\n\nfunc (m *Map) Scan(oid uint32, formatCode int16, src []byte, dst any) error {\n\tif dst == nil {\n\t\treturn nil\n\t}\n\n\tplan := m.PlanScan(oid, formatCode, dst)\n\treturn plan.Scan(src, dst)\n}\n\nvar ErrScanTargetTypeChanged = errors.New(\"scan target type changed\")\n\nfunc codecScan(codec Codec, m *Map, oid uint32, format int16, src []byte, dst any) error {\n\tscanPlan := codec.PlanScan(m, oid, format, dst)\n\tif scanPlan == nil {\n\t\treturn fmt.Errorf(\"PlanScan did not find a plan\")\n\t}\n\treturn scanPlan.Scan(src, dst)\n}\n\nfunc codecDecodeToTextFormat(codec Codec, m *Map, oid uint32, format int16, src []byte) (driver.Value, error) {\n\tif src == nil {\n\t\treturn nil, nil\n\t}\n\n\tif format == TextFormatCode {\n\t\treturn string(src), nil\n\t} else {\n\t\tvalue, err := codec.DecodeValue(m, oid, format, src)","sourceCodeStart":1153,"sourceCodeEnd":1189,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/pgtype.go#L1153-L1189","documentation":"Sentinel ErrScanTargetTypeChanged: a cached scan plan was invoked with a destination whose concrete type no longer matches the type the plan was built for (e.g. a *bool plan receiving a *string). It guards against type confusion between plan selection and execution; the mismatched destination type is the faulty input and usually indicates a driver-internal caching bug rather than user error.","triggerScenarios":"Thrown at pgtype/pgtype.go:1171 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["If it surfaces in application code, report it as a pgx issue with the types involved","Ensure the same destination variable/type is used between Rows.Scan planning and scanning"],"exampleFix":null,"handlingStrategy":"try-catch","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"}