{"record":{"id":"a6c21457613972bf","repo":"Tencent/WeKnora","slug":"casting-to-system-type-s-is-not-allowed","errorCode":null,"errorMessage":"casting to system type '%s' is not allowed","messagePattern":"casting to system type '(.+?)' is not allowed","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/utils/inject.go","lineNumber":1557,"sourceCode":"\t\t}\n\t}\n\n\t// Check for column references\n\tif cr := node.GetColumnRef(); cr != nil {\n\t\tif err := v.validateColumnRef(cr); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Check for type casts\n\tif tc := node.GetTypeCast(); tc != nil {\n\t\tif err := v.validateNode(tc.Arg, result); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif tc.TypeName != nil {\n\t\t\ttypeName := v.getTypeName(tc.TypeName)\n\t\t\tif strings.HasPrefix(strings.ToLower(typeName), \"pg_\") {\n\t\t\t\treturn fmt.Errorf(\"casting to system type '%s' is not allowed\", typeName)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Recursively check A_Expr (expressions)\n\tif ae := node.GetAExpr(); ae != nil {\n\t\tif err := v.validateNode(ae.Lexpr, result); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := v.validateNode(ae.Rexpr, result); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Check BoolExpr (AND, OR, NOT)\n\tif be := node.GetBoolExpr(); be != nil {\n\t\tfor _, arg := range be.Args {\n\t\t\tif err := v.validateNode(arg, result); err != nil {","sourceCodeStart":1539,"sourceCodeEnd":1575,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/utils/inject.go#L1539-L1575","documentation":"Type-cast guard in validateNode: a TypeCast targets a system type whose name begins with 'pg_' (e.g. pg_catalog system types), which is disallowed to prevent information disclosure or unsafe coercions through system type machinery.","triggerScenarios":"Thrown at internal/utils/inject.go:1557 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Cast to a standard user-facing type instead (text, int, etc.)","Remove the cast if the column already has the right type","Avoid referencing pg_ system types in generated SQL"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}