{"record":{"id":"a8db93bb243b4b99","repo":"Mintplex-Labs/anything-llm","slug":"response-error-failed-to-create-system-promp","errorCode":null,"errorMessage":"${response.error || \"Failed to create system prompt\"}","messagePattern":"\\$\\{response\\.error \\|\\| \"Failed to create system prompt\"\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/models/communityHub.js","lineNumber":176,"sourceCode":"   * Create a new system prompt in the community hub\n   * @param {Object} data - The system prompt data\n   * @param {string} data.name - The name of the prompt\n   * @param {string} data.description - The description of the prompt\n   * @param {string} data.prompt - The actual system prompt text\n   * @param {string[]} data.tags - Array of tags\n   * @param {string} data.visibility - Either 'public' or 'private'\n   * @returns {Promise<{success: boolean, error: string | null}>}\n   */\n  createSystemPrompt: async (data) => {\n    return await fetch(`${API_BASE}/community-hub/system-prompt/create`, {\n      method: \"POST\",\n      headers: baseHeaders(),\n      body: JSON.stringify(data),\n    })\n      .then(async (res) => {\n        const response = await res.json();\n        if (!res.ok)\n          throw new Error(response.error || \"Failed to create system prompt\");\n        return { success: true, error: null, itemId: response.item?.id };\n      })\n      .catch((e) => ({\n        success: false,\n        error: e.message,\n      }));\n  },\n\n  /**\n   * Create a new agent flow in the community hub\n   * @param {Object} data - The agent flow data\n   * @returns {Promise<{success: boolean, error: string | null}>}\n   */\n  createAgentFlow: async (data) => {\n    return await fetch(`${API_BASE}/community-hub/agent-flow/create`, {\n      method: \"POST\",\n      headers: baseHeaders(),\n      body: JSON.stringify(data),","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/frontend/src/models/communityHub.js#L158-L194","documentation":"Thrown from `createSystemPrompt` on a non-ok `POST /api/community-hub/system-prompt/create`. Reads `response.error`, falling back to 'Failed to create system prompt'. Validation 4xx is the most common cause: the prompt payload (name, visibility, prompt text, tags) must satisfy the hub schema.","triggerScenarios":"Missing required fields (name/prompt/visibility), invalid `visibility` value (not 'public'/'private'), tags not an array or over the limit, 401 non-admin, 409 duplicate name, 500 persistence failure.","commonSituations":"Submitting an incomplete form; visibility typo; too many/oversized tags; session expired before submit.","solutions":["Validate the payload shape client-side (non-empty name+prompt, visibility ∈ {public,private}, tags array).","Read `error` from the returned `{ success, error }` for the precise reason.","On 401 re-authenticate; on 409 rename the prompt.","Trim fields and enforce tag count/length limits before posting."],"exampleFix":"// before\nawait CommunityHub.createSystemPrompt(formData);\n\n// after\nconst payload = {\n  name: String(formData.name).trim(),\n  prompt: String(formData.prompt).trim(),\n  visibility: ['public','private'].includes(formData.visibility) ? formData.visibility : 'private',\n  tags: Array.isArray(formData.tags) ? formData.tags.slice(0, 10) : [],\n};\nif (!payload.name || !payload.prompt) throw new Error('Name and prompt are required');\nconst { success, error } = await CommunityHub.createSystemPrompt(payload);\nif (!success) throw new Error(error || 'Failed to create system prompt');","handlingStrategy":"validation","validationCode":"function validateSystemPromptPayload(data) {\n  const name = String(data?.name || '').trim();\n  const prompt = String(data?.prompt || '').trim();\n  const visibility = data?.visibility;\n  if (!name) throw new Error('System prompt name is required');\n  if (!prompt) throw new Error('System prompt text is required');\n  if (!['public','private'].includes(visibility)) throw new Error(\"visibility must be 'public' or 'private'\");\n  if (!Array.isArray(data?.tags)) throw new Error('tags must be an array');\n}","typeGuard":"function isSystemPromptPayload(v) {\n  return !!v && typeof v === 'string' && typeof v.name === 'string' && typeof v.prompt === 'string'\n    && ['public','private'].includes(v.visibility) && Array.isArray(v.tags);\n}","tryCatchPattern":"const { success, error, itemId } = await CommunityHub.createSystemPrompt(data);\nif (!success) showToast(error || 'Failed to create system prompt');","preventionTips":["Enforce name+prompt non-empty, valid visibility, and tag limits client-side.","Read the returned `error` for precise validation reasons.","Re-authenticate on 401; rename on 409 duplicates."],"tags":["frontend","community-hub","system-prompt","validation","fetch"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}