{"record":{"id":"85d6a3ce3695a004","repo":"bytebase/bytebase","slug":"number-payload-is-required-for-this-rule-85d6a3","errorCode":null,"errorMessage":"number_payload is required for this rule","messagePattern":"number_payload is required for this rule","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/plugin/advisor/oracle/rule_column_maximum_varchar_length.go","lineNumber":37,"sourceCode":")\n\nfunc init() {\n\tadvisor.Register(storepb.Engine_ORACLE, storepb.SQLReviewRule_COLUMN_MAXIMUM_VARCHAR_LENGTH, &ColumnMaximumVarcharLengthAdvisor{})\n}\n\n// ColumnMaximumVarcharLengthAdvisor is the advisor checking for maximum varchar length.\ntype ColumnMaximumVarcharLengthAdvisor struct {\n}\n\n// Check checks for maximum varchar length.\nfunc (*ColumnMaximumVarcharLengthAdvisor) Check(_ context.Context, checkCtx advisor.Context) ([]*storepb.Advice, error) {\n\tlevel, err := advisor.NewStatusBySQLReviewRuleLevel(checkCtx.Rule.Level)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tnumberPayload := checkCtx.Rule.GetNumberPayload()\n\tif numberPayload == nil {\n\t\treturn nil, errors.New(\"number_payload is required for this rule\")\n\t}\n\n\tif int(numberPayload.Number) <= 0 {\n\t\treturn nil, nil\n\t}\n\n\trule := NewColumnMaximumVarcharLengthRule(level, checkCtx.Rule.Type.String(), int(numberPayload.Number))\n\n\treturn RunOmniRules(checkCtx.ParsedStatements, []OmniRule{rule})\n}\n\n// ColumnMaximumVarcharLengthRule is the rule implementation for maximum varchar length.\ntype ColumnMaximumVarcharLengthRule struct {\n\tBaseRule\n\n\tmaximum int\n}\n","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/bytebase/bytebase/blob/1870550677fe08f0d2a78c07acd27541464eb945/backend/plugin/advisor/oracle/rule_column_maximum_varchar_length.go#L19-L55","documentation":"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.","triggerScenarios":"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.","commonSituations":"Rule JSON/config round-trips dropping unset payloads; automation building rules with only type and level; test fixtures missing payloads.","solutions":["Set NumberPayload on the rule (e.g. Number: 4000) before Check; keep it positive since the rule skips non-positive values.","Re-save the SQL review policy with the varchar limit filled in.","Validate enabled rules at policy load: payload-requiring types must have a payload.","Update rule-generation code to always attach numberPayload for this type."],"exampleFix":"// before\nrule := &storepb.SQLReviewRule{Type: storepb.SQLReviewRule_COLUMN_MAXIMUM_VARCHAR_LENGTH, Level: storepb.SQLReviewRule_WARNING}\n// after\nrule := &storepb.SQLReviewRule{Type: storepb.SQLReviewRule_COLUMN_MAXIMUM_VARCHAR_LENGTH, Level: storepb.SQLReviewRule_WARNING,\n\tPayload: &storepb.SQLReviewRule_NumberPayload{NumberPayload: &storepb.SQLReviewRuleNumberPayload{Number: 4000}}}","handlingStrategy":"validation","validationCode":"if rule.GetNumberPayload() == nil || rule.GetNumberPayload().Number <= 0 {\n\treturn fmt.Errorf(\"rule %s requires a positive number_payload\", rule.Type)\n}","typeGuard":"func hasPositiveNumberPayload(rule *storepb.SQLReviewRule) bool {\n\tnp := rule.GetNumberPayload()\n\treturn np != nil && np.Number > 0\n}","tryCatchPattern":"advices, err := advisor.Check(ctx, checkCtx)\nif err != nil {\n\tif strings.Contains(err.Error(), \"number_payload is required\") {\n\t\t// fix rule config before rerunning\n\t}\n\treturn err\n}","preventionTips":["Set a positive varchar-length limit when enabling the rule","Validate rule payloads on policy load","Keep rule construction in one place that enforces payloads","Test protojson round-trips preserve payload fields"],"tags":["oracle","sql-review","advisor","config"],"backgroundTag":"missing-required-config-field","analyzedSha":"1870550677fe08f0d2a78c07acd27541464eb945","analyzedAt":"2026-09-06T21:16:13.665Z","contentChangedAt":"2026-09-06T21:16:13.665Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}