{"record":{"id":"c07b9a908f202764","repo":"linshenkx/prompt-optimizer","slug":"missing-prompt-garden-base-url","errorCode":null,"errorMessage":"Missing Prompt Garden base URL","messagePattern":"Missing Prompt Garden base URL","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ui/src/utils/prompt-garden-suggestions.ts","lineNumber":122,"sourceCode":"      ? (source as PromptGardenSuggestionSource)\n      : null,\n  }\n}\n\nconst buildFallbackBrowseUrl = (gardenBaseUrl: string, mode: string): string => {\n  const url = new URL(`${gardenBaseUrl}/prompts`)\n  if (mode) {\n    url.searchParams.set('mode', mode)\n  }\n  return url.toString()\n}\n\nexport const buildPromptGardenSuggestionsUrl = (\n  options: FetchPromptGardenSuggestionsOptions,\n): string => {\n  const gardenBaseUrl = normalizeBaseUrl(options.gardenBaseUrl)\n  if (!gardenBaseUrl) {\n    throw new Error('Missing Prompt Garden base URL')\n  }\n\n  const url = new URL(`${gardenBaseUrl}/api/public/prompts/suggestions`)\n  url.searchParams.set('mode', options.mode)\n  url.searchParams.set('limit', String(options.limit ?? DEFAULT_LIMIT))\n  url.searchParams.set('strategy', options.strategy ?? 'mixed')\n\n  const exclude = Array.from(new Set((options.exclude ?? []).map((item) => item.trim()).filter(Boolean)))\n  if (exclude.length > 0) {\n    url.searchParams.set('exclude', exclude.join(','))\n  }\n\n  const locale = normalizeString(options.locale)\n  if (locale) {\n    url.searchParams.set('locale', locale)\n  }\n\n  return url.toString()","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/ui/src/utils/prompt-garden-suggestions.ts#L104-L140","documentation":"Thrown by buildPromptGardenSuggestionsUrl when no Prompt Garden base URL can be resolved. The function normalizes options.gardenBaseUrl and requires a non-empty result, because the suggestions endpoint URL cannot be constructed without it. It is called by the url helper used by fetchPromptGardenSuggestions.","triggerScenarios":"Calling fetchPromptGardenSuggestions or buildPromptGardenSuggestionsUrl without gardenBaseUrl; passing an empty string, whitespace, or a value that normalizeBaseUrl reduces to empty (e.g. malformed URL).","commonSituations":"Missing environment variable (e.g. VITE_PROMPT_GARDEN_BASE_URL) in the deployment config; dev environment where the garden service URL was never wired up; passing undefined options because the config object was not loaded yet.","solutions":["Pass a valid gardenBaseUrl in the options object","Set the Prompt Garden base URL environment variable for your environment","Ensure config is loaded before calling fetchPromptGardenSuggestions; guard the call behind a config check","Verify the URL survives normalizeBaseUrl (scheme present, not whitespace-only)"],"exampleFix":"// before\nconst suggestions = await fetchPromptGardenSuggestions({ mode: 'recent' })\n// after\nconst gardenBaseUrl = import.meta.env.VITE_PROMPT_GARDEN_BASE_URL\nif (!gardenBaseUrl) throw new Error('Prompt Garden not configured')\nconst suggestions = await fetchPromptGardenSuggestions({ mode: 'recent', gardenBaseUrl })","handlingStrategy":"validation","validationCode":"const gardenBaseUrl = import.meta.env.VITE_PROMPT_GARDEN_BASE_URL\nif (!gardenBaseUrl || !gardenBaseUrl.trim()) {\n  // skip feature or show config UI instead of calling\n}","typeGuard":"const hasGardenBaseUrl = (\n  options: FetchPromptGardenSuggestionsOptions,\n): boolean => Boolean(normalizeBaseUrl(options.gardenBaseUrl))","tryCatchPattern":"try {\n  const url = buildPromptGardenSuggestionsUrl(options)\n} catch (error) {\n  if ((error as Error).message === 'Missing Prompt Garden base URL') {\n    // degrade gracefully: hide suggestions feature\n  }\n}","preventionTips":["Fail fast at app startup if the garden URL env var is missing","Centralize garden config in one typed config loader","Feature-flag the suggestions UI on presence of the base URL"],"tags":["configuration","missing-url","prompt-garden","env-var"],"backgroundTag":"missing-env-var","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}