{"record":{"id":"659d1799e1ca7d09","repo":"Tencent/WeKnora","slug":"s-exceeds-d-characters","errorCode":null,"errorMessage":"%s exceeds %d characters","messagePattern":"(.+?) exceeds (.+?) characters","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/types/prompt_instructions.go","lineNumber":85,"sourceCode":"\treturn validatePromptInstructionFields(fields)\n}\n\n// ValidateEffectiveProcessPromptInstructions checks length limits on the\n// merged per-upload effective config.\nfunc ValidateEffectiveProcessPromptInstructions(eff EffectiveProcessConfig) error {\n\tfields := map[string]string{\n\t\t\"table metadata instructions\":      eff.ChunkingConfig.TableMetadataInstructions,\n\t\t\"image instructions\":               eff.VLMConfig.CustomInstructions,\n\t\t\"question generation instructions\": eff.QuestionGenerationConfig.CustomInstructions,\n\t\t\"graph extraction instructions\":    eff.ExtractConfig.CustomInstructions,\n\t}\n\treturn validatePromptInstructionFields(fields)\n}\n\nfunc validatePromptInstructionFields(fields map[string]string) error {\n\tfor name, value := range fields {\n\t\tif len([]rune(value)) > MaxCustomPromptInstructionsLength {\n\t\t\treturn fmt.Errorf(\"%s exceeds %d characters\", name, MaxCustomPromptInstructionsLength)\n\t\t}\n\t}\n\treturn nil\n}\n","sourceCodeStart":67,"sourceCodeEnd":90,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/types/prompt_instructions.go#L67-L90","documentation":"validatePromptInstructionFields enforces MaxCustomPromptInstructionsLength on every knowledge-base / effective-process prompt instruction field. If any field's rune length exceeds the limit, it fails with \"<fieldName> exceeds <limit> characters\".","triggerScenarios":"Calling ValidateKnowledgeBasePromptInstructions or ValidateEffectiveProcessPromptInstructions with a map of prompt instruction fields where any value exceeds MaxCustomPromptInstructionsLength runes.","commonSituations":"Users pasting very long custom instructions into a knowledge-base or process editor, programmatic imports of large prompt templates, or accumulated instruction text growing past the cap across edits.","solutions":["Trim the offending field to MaxCustomPromptInstructionsLength runes before validation","Show the character count in the UI and block submission over the limit","Split long instructions across multiple fields or use summarization","Check the constant's current value — if the limit legitimately changed, update stored content or migrate"],"exampleFix":"// before\ninstructions[\"system\"] = veryLongText // > limit\n// after\nrunes := []rune(veryLongText)\nif len(runes) > MaxCustomPromptInstructionsLength {\n    instructions[\"system\"] = string(runes[:MaxCustomPromptInstructionsLength])\n}","handlingStrategy":"validation","validationCode":"func withinLimit(fields map[string]string) bool {\n    for _, v := range fields {\n        if len([]rune(v)) > MaxCustomPromptInstructionsLength { return false }\n    }\n    return true\n}","typeGuard":"func fieldWithinLimit(s string) bool { return len([]rune(s)) <= MaxCustomPromptInstructionsLength }","tryCatchPattern":"if err := validatePromptInstructionFields(fields); err != nil {\n    // err text names the offending field, e.g. \"system exceeds 2000 characters\"\n    fieldName := strings.SplitN(err.Error(), \" \", 2)[0]\n    // highlight fieldName in the UI\n}","preventionTips":["Enforce a character counter in editors with the same limit and rune counting","Validate before save/submit, not only server-side","Watch for limit changes across versions and re-validate stored content after upgrades"],"tags":["validation","prompt","limits","go"],"backgroundTag":"input-too-long","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}