{"record":{"id":"70dd0941d8db29c8","repo":"t8y2/dbx","slug":"failed-to-read-enum-values-w-70dd09","errorCode":null,"errorMessage":"failed to read enum values: %w","messagePattern":"failed to read enum values: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/vastbase-go/vastbase_metadata.go","lineNumber":726,"sourceCode":"\tproperties.AnalyzeFunction = nullStringPtr(analyzeFn)\n\tif typlen.Valid && typlen.Int64 > 0 {\n\t\tvalue := int32(typlen.Int64)\n\t\tproperties.Internallength = &value\n\t}\n\tproperties.PassedByValue = &typbyval\n\tif typalign != \"\" {\n\t\tproperties.Alignment = &typalign\n\t}\n\tif typstorage != \"\" {\n\t\tproperties.Storage = &typstorage\n\t}\n\treturn properties\n}\n\nfunc (s *server) customTypeEnumMembers(sqlTemplate string, oid int64) ([]customTypeMember, error) {\n\trows, err := s.metadataQuery(fmt.Sprintf(sqlTemplate, oid))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read enum values: %w\", err)\n\t}\n\tdefer rows.Close()\n\tvar members []customTypeMember\n\tindex := 0\n\tfor rows.Next() {\n\t\tvar label string\n\t\tvar sortOrder float64\n\t\tif err := rows.Scan(&label, &sortOrder); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\t// enumsortorder is float4; ALTER TYPE ... ADD VALUE BEFORE/AFTER can\n\t\t// yield fractional values. Use the ORDER BY position for a unique key.\n\t\tindex++\n\t\tmembers = append(members, customTypeMember{Ordinal: int32(index), EnumValue: &label})\n\t}\n\treturn members, rows.Err()\n}\n","sourceCodeStart":708,"sourceCodeEnd":744,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/vastbase-go/vastbase_metadata.go#L708-L744","documentation":"This error wraps a failure of the metadata query that reads enum member values (enumsortorder/enumlabel) from the catalog for an enum custom type. It is returned by customTypeEnumMembers when the query itself fails to execute (connection, permissions, SQL syntax against the catalog). It is not a 'type not found' error — the enum row was already located; only reading its values failed.","triggerScenarios":"Calling custom type details for an enum type when the underlying metadataQuery for enum members errors: connection dropped mid-session, insufficient privileges on sys_catalog/pg_catalog enum views, or catalog query incompatibility (e.g. postgresCatalog mode flag mismatch with actual server catalog).","commonSituations":"Network interruption while introspecting an enum; restricted monitoring account lacking catalog read privileges; driver mode configured for pg_catalog on a server that only exposes sys_catalog (or vice versa).","solutions":["Check DB connectivity and re-run the introspection; inspect the wrapped cause (%w) for the root error.","Grant the connecting user SELECT on the catalog enum views (pg_enum/sys_catalog equivalents).","Confirm s.mode.postgresCatalog matches the actual server catalog flavor so the correct catalog queries are used.","Retry after transient network errors; escalate if the wrapped error is a SQL syntax/permission error."],"exampleFix":"// before\n// introspecting with a user lacking catalog access\nsrv, _ := New(serverCfg) // user 'app_ro' without catalog SELECT\n_, err := srv.CustomTypeDetails(\"public\", \"color_enum\")\n// failed to read enum values: permission denied ...\n\n// after\n// grant catalog read access to the introspection role\n// GRANT SELECT ON pg_enum TO app_ro;","handlingStrategy":"retry","validationCode":"// verify connectivity and privileges up front\nif err := db.Ping(); err != nil { return err }\nvar n int\nif err := db.QueryRow(\"SELECT COUNT(*) FROM pg_enum LIMIT 1\").Scan(&n); err != nil {\n    return fmt.Errorf(\"no catalog enum access: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"details, err := srv.CustomTypeDetails(schema, name)\nif err != nil {\n    var wrapped error\n    if errors.As(err, &wrapped) && isTransient(wrapped) {\n        // retry with backoff\n    }\n    return fmt.Errorf(\"enum introspection failed: %w\", err)\n}","preventionTips":["Grant catalog SELECT privileges to the introspection role.","Keep connections healthy; use pool health checks before long introspection runs.","Match the driver catalog mode (postgresCatalog) to the actual server."],"tags":["vastbase","metadata","database","enum"],"backgroundTag":"metadata-query-failed","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}