bytebase/bytebase · error

function %q signature %q

Error message

function %q signature %q

What it means

This error is returned when the fallback path of wtInstallFunction cannot parse the function's argument types from fn.Signature. When the function body definition is absent or fails to parse as a CreateFunctionStmt, the loader falls back to rebuilding the signature, and wtParseFuncArgTypes failed on that string. The error is wrapped with the function name and signature for diagnosis.

Source

Thrown at backend/plugin/schema/pg/walk_through_loader.go:870

func wtInstallFunction(cat *catalog.Catalog, obj *wtObjectEntry) error {
	fn := obj.funcMeta
	if fn.Definition != "" {
		nodes, err := omniparser.Parse(fn.Definition)
		if err == nil && nodes != nil && len(nodes.Items) == 1 {
			node := nodes.Items[0]
			if raw, ok := node.(*ast.RawStmt); ok {
				node = raw.Stmt
			}
			if parsed, ok := node.(*ast.CreateFunctionStmt); ok {
				return cat.CreateFunctionStmt(parsed)
			}
		}
	}
	// Fallback: build from signature.
	argTypes, err := wtParseFuncArgTypes(fn.Signature)
	if err != nil {
		return errors.Wrapf(err, "function %q signature %q", fn.Name, fn.Signature)
	}
	params := make([]ast.Node, 0, len(argTypes))
	for i, at := range argTypes {
		tn, err := wtTypeNameFromString(at)
		if err != nil {
			return errors.Wrapf(err, "function %q arg %d", fn.Name, i)
		}
		params = append(params, &ast.FunctionParameter{
			ArgType: tn,
			Mode:    ast.FUNC_PARAM_IN,
		})
	}
	stmt := &ast.CreateFunctionStmt{
		Funcname:   wtQualifiedList(obj.schema, fn.Name),
		ReturnType: wtPseudoTextTypeName(),
	}
	if len(params) > 0 {
		stmt.Parameters = &ast.List{Items: params}

View on GitHub (pinned to 1870550677)

Solutions

  1. Inspect fn.Signature and confirm it is a plain comma-separated list of type names like "integer, text"
  2. Remove parameter names, defaults, and OUT/INOUT annotations from the signature; keep only input type names
  3. If possible, fix the source so funcMeta.Definition contains a full CREATE FUNCTION statement that parses directly, bypassing the fallback
  4. Verify each type name individually with wtTypeNameFromString to find the offending argument

Example fix

// before
Signature: "a integer DEFAULT 1, b text[]"
// after
Signature: "integer, text[]"
Defensive patterns

Strategy: validation

Validate before calling

func validFuncSignature(sig string) bool {
	if strings.TrimSpace(sig) == "" {
		return false
	}
	_, err := wtParseFuncArgTypes(sig)
	return err == nil
}

Try / catch

if err := wtInstallFunction(cat, obj); err != nil {
	if strings.Contains(err.Error(), "signature") {
		log.Printf("function %s: bad signature %q: %v", obj.funcMeta.Name, obj.funcMeta.Signature, err)
		return nil
	}
	return err
}

Prevention

When it happens

Trigger: wtInstallReal installs a function entry whose funcMeta.Definition is empty or unparseable, forcing the signature fallback, and fn.Signature does not match the expected comma-separated type list format (e.g. contains DEFAULT values, OUT parameters, named args, or schema-qualified types the parser chokes on).

Common situations: Catalog dumps from Postgres with complex signatures (VARIADIC, table arguments, named parameters); fixtures with typos in the signature string; functions whose signature was recorded in a non-canonical format.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of bytebase/bytebase@1870550677 (2026-09-06). Data as JSON: /api/errors/a9087d2d544d6c28. Report an issue: GitHub.