Tencent/WeKnora · error

casting to system type '%s' is not allowed

Error message

casting to system type '%s' is not allowed

What it means

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.

Source

Thrown at internal/utils/inject.go:1557

		}
	}

	// Check for column references
	if cr := node.GetColumnRef(); cr != nil {
		if err := v.validateColumnRef(cr); err != nil {
			return err
		}
	}

	// Check for type casts
	if tc := node.GetTypeCast(); tc != nil {
		if err := v.validateNode(tc.Arg, result); err != nil {
			return err
		}
		if tc.TypeName != nil {
			typeName := v.getTypeName(tc.TypeName)
			if strings.HasPrefix(strings.ToLower(typeName), "pg_") {
				return fmt.Errorf("casting to system type '%s' is not allowed", typeName)
			}
		}
	}

	// Recursively check A_Expr (expressions)
	if ae := node.GetAExpr(); ae != nil {
		if err := v.validateNode(ae.Lexpr, result); err != nil {
			return err
		}
		if err := v.validateNode(ae.Rexpr, result); err != nil {
			return err
		}
	}

	// Check BoolExpr (AND, OR, NOT)
	if be := node.GetBoolExpr(); be != nil {
		for _, arg := range be.Args {
			if err := v.validateNode(arg, result); err != nil {

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Cast to a standard user-facing type instead (text, int, etc.)
  2. Remove the cast if the column already has the right type
  3. Avoid referencing pg_ system types in generated SQL
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/utils/inject.go:1557 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/a6c21457613972bf. Report an issue: GitHub.