bytebase/bytebase · error

number_payload is required for this rule

Error message

number_payload is required for this rule

What it means

The Oracle 'column maximum varchar length' advisor requires a NumberPayload giving the maximum VARCHAR2 length allowed. Check returns this error when the payload is nil because the rule has no length limit to compare against. The rule was enabled without its numeric payload.

Source

Thrown at backend/plugin/advisor/oracle/rule_column_maximum_varchar_length.go:37

)

func init() {
	advisor.Register(storepb.Engine_ORACLE, storepb.SQLReviewRule_COLUMN_MAXIMUM_VARCHAR_LENGTH, &ColumnMaximumVarcharLengthAdvisor{})
}

// ColumnMaximumVarcharLengthAdvisor is the advisor checking for maximum varchar length.
type ColumnMaximumVarcharLengthAdvisor struct {
}

// Check checks for maximum varchar length.
func (*ColumnMaximumVarcharLengthAdvisor) Check(_ context.Context, checkCtx advisor.Context) ([]*storepb.Advice, error) {
	level, err := advisor.NewStatusBySQLReviewRuleLevel(checkCtx.Rule.Level)
	if err != nil {
		return nil, err
	}
	numberPayload := checkCtx.Rule.GetNumberPayload()
	if numberPayload == nil {
		return nil, errors.New("number_payload is required for this rule")
	}

	if int(numberPayload.Number) <= 0 {
		return nil, nil
	}

	rule := NewColumnMaximumVarcharLengthRule(level, checkCtx.Rule.Type.String(), int(numberPayload.Number))

	return RunOmniRules(checkCtx.ParsedStatements, []OmniRule{rule})
}

// ColumnMaximumVarcharLengthRule is the rule implementation for maximum varchar length.
type ColumnMaximumVarcharLengthRule struct {
	BaseRule

	maximum int
}

View on GitHub (pinned to 1870550677)

Solutions

  1. Set NumberPayload on the rule (e.g. Number: 4000) before Check; keep it positive since the rule skips non-positive values.
  2. Re-save the SQL review policy with the varchar limit filled in.
  3. Validate enabled rules at policy load: payload-requiring types must have a payload.
  4. Update rule-generation code to always attach numberPayload for this type.

Example fix

// before
rule := &storepb.SQLReviewRule{Type: storepb.SQLReviewRule_COLUMN_MAXIMUM_VARCHAR_LENGTH, Level: storepb.SQLReviewRule_WARNING}
// after
rule := &storepb.SQLReviewRule{Type: storepb.SQLReviewRule_COLUMN_MAXIMUM_VARCHAR_LENGTH, Level: storepb.SQLReviewRule_WARNING,
	Payload: &storepb.SQLReviewRule_NumberPayload{NumberPayload: &storepb.SQLReviewRuleNumberPayload{Number: 4000}}}
Defensive patterns

Strategy: validation

Validate before calling

if rule.GetNumberPayload() == nil || rule.GetNumberPayload().Number <= 0 {
	return fmt.Errorf("rule %s requires a positive number_payload", rule.Type)
}

Type guard

func hasPositiveNumberPayload(rule *storepb.SQLReviewRule) bool {
	np := rule.GetNumberPayload()
	return np != nil && np.Number > 0
}

Try / catch

advices, err := advisor.Check(ctx, checkCtx)
if err != nil {
	if strings.Contains(err.Error(), "number_payload is required") {
		// fix rule config before rerunning
	}
	return err
}

Prevention

When it happens

Trigger: Calling Check with the Oracle column maximum varchar length rule while Rule.NumberPayload is unset — typically a policy created or imported without the number field.

Common situations: Rule JSON/config round-trips dropping unset payloads; automation building rules with only type and level; test fixtures missing payloads.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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