{"record":{"id":"7fd5a39161697c4c","repo":"different-ai/openwork","slug":"failed-to-create-the-imported-plugin","errorCode":null,"errorMessage":"Failed to create the imported plugin.","messagePattern":"Failed to create the imported plugin\\.","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ee/apps/den-web/app/(den)/dashboard/_components/plugin-editor-screen.tsx","lineNumber":215,"sourceCode":"              access: {\n                orgWide: shareOrgWide,\n                memberIds: shareOrgWide || !orgContext ? [] : [orgContext.currentMember.id],\n                teamIds: [],\n              },\n              authType: draft.authType,\n              credentialMode: draft.credentialMode,\n              description: description.trim() || null,\n              githubUrl: draft.githubUrl,\n              marketplaceId: marketplaceId || undefined,\n              name: name.trim(),\n              selectedSkillKeys: draft.selectedSkillKeys,\n              selectedServerKeys: draft.selectedServerKeys,\n            }),\n          },\n          30000,\n        );\n        if (!result.response.ok) {\n          throw getRequestError(result.payload, result.response, \"Failed to create the imported plugin.\");\n        }\n        const item = isRecord(result.payload) && isRecord(result.payload.item) ? result.payload.item : null;\n        const plugin = item && isRecord(item.plugin) ? item.plugin : null;\n        pluginId = plugin && typeof plugin.id === \"string\" ? plugin.id : null;\n      });\n      if (!pluginId) throw new Error(\"The plugin was created, but no id was returned.\");\n\n      clearPluginImportDraft();\n      await queryClient.invalidateQueries({ queryKey: pluginQueryKeys.all });\n      router.push(getPluginRoute(orgSlug, pluginId));\n      router.refresh();\n    } catch (error) {\n      setSaveError(error instanceof Error ? error.message : \"Failed to create the imported plugin.\");\n    } finally {\n      setSaving(false);\n    }\n  }\n","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/dashboard/_components/plugin-editor-screen.tsx#L197-L233","documentation":"createImportedPlugin in plugin-editor-screen.tsx throws this fixed message when the import-and-create POST (30s timeout) returns a non-ok response. Unlike the generic postJson path, no status is interpolated, so the server payload attached by getRequestError is the key diagnostic. Means the Den API failed to materialize a plugin from the import draft.","triggerScenarios":"The import-create POST with the serialized draft (including selectedServerKeys) returns 4xx/5xx: empty or invalid selectedServerKeys (400), GitHub source unreachable server-side (502), permission denied (403), or import size/timeout limits hit (413/504).","commonSituations":"Importing a GitHub plugin whose repo is private or rate-limited; selecting server keys that were removed from the org; importing a very large plugin manifest that exceeds the 30s window.","solutions":["Re-run the import preview (previewImport) to refresh valid server keys before retrying the create.","Reduce the draft scope: deselect unavailable/errored server keys and retry.","For 401/403, re-authenticate or confirm import permission in the org.","If 502/504, verify the GitHub source URL is public/reachable and retry later."],"exampleFix":"// before: create straight from stale draft\nawait createImportedPlugin(draft);\n// after: refresh selection against a fresh preview\nconst preview = await previewImport(draft.githubUrl);\ndraft.selectedServerKeys = draft.selectedServerKeys.filter((k) => preview.serverKeys.includes(k));\nawait createImportedPlugin(draft);","handlingStrategy":"try-catch","validationCode":"if (!draft.githubUrl) throw new Error('Run the GitHub import preview first.');\nif (!draft.selectedServerKeys?.length) throw new Error('Select at least one server key to import.');","typeGuard":"function hasSelectedKeys(v: unknown): v is { selectedServerKeys: string[] } {\n  return typeof v === 'object' && v !== null &&\n    Array.isArray((v as Record<string, unknown>).selectedServerKeys) &&\n    ((v as { selectedServerKeys: unknown[] }).selectedServerKeys.length > 0);\n}","tryCatchPattern":"try {\n  const id = await createImportedPlugin(draft);\n  if (!id) throw new Error('The plugin was created, but no id was returned.');\n} catch (e) {\n  await refreshImportPreview();\n  toast(e instanceof Error ? e.message : String(e));\n}","preventionTips":["Always run the import preview immediately before create so server keys are current.","Filter selectedServerKeys against the preview result before submitting.","Break very large imports into smaller selections to stay under the 30s timeout.","Verify the GitHub source is public/reachable before starting an import."],"tags":["http","api","plugin-import","github"],"backgroundTag":"http-non-ok-response","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}