{"record":{"id":"e35056b023c4f87e","repo":"Budibase/budibase","slug":"unsupported-import-type","errorCode":null,"errorMessage":"Unsupported import type","messagePattern":"Unsupported import type","errorType":"http","errorClass":"HTTPError","httpStatus":400,"severity":"error","filePath":"packages/server/src/api/controllers/query/import/index.ts","lineNumber":195,"sourceCode":"      importer.getSource().getImportSource(),\n      cache.TTL.ONE_DAY * OPENAPI_SPEC_CACHE_TTL_DAYS\n    )\n  }\n\n  return importer\n}\n\nexport class RestImporter {\n  private source!: ImportSource\n\n  private constructor() {}\n\n  static init = async (data: string, type?: string) => {\n    const importer = new RestImporter()\n    if (type) {\n      const factory = SOURCE_FACTORIES[type]\n      if (!factory) {\n        throw new HTTPError(\"Unsupported import type\", 400)\n      }\n\n      const source = factory()\n      await source.load(data)\n      importer.source = source\n      return importer\n    } else {\n      for (let source of [new OpenAPI3(), new OpenAPI2(), new Curl()]) {\n        if (await source.tryLoad(data)) {\n          importer.source = source\n          break\n        }\n      }\n    }\n    if (!importer.source) {\n      throw new HTTPError(\"Unsupported import data\", 400)\n    }\n    return importer","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/api/controllers/query/import/index.ts#L177-L213","documentation":"RestImporter.init accepts an explicit `type` and looks it up in SOURCE_FACTORIES, which only knows 'openapi2.0', 'openapi3.0', and 'curl'. If a type string is supplied that has no factory, it throws HTTPError 400 'Unsupported import type'.","triggerScenarios":"Calling RestImporter.init(data, type) with type values like 'openapi', 'swagger', 'OpenAPI3.0' (wrong case), 'postman', or 'graphql'.","commonSituations":"Client sends a type label from its own enum that doesn't match the server's keys; after a version change the type naming shifted (e.g. 'openapi2.0' vs 'openapi2'); passing a MIME type like 'application/json' instead of the importer name.","solutions":["Use one of the supported exact type strings: 'openapi2.0', 'openapi3.0', or 'curl'","Omit the `type` argument entirely to let init auto-detect the format from the data","Normalize/case the type string before calling (keys are lowercase, exact match)"],"exampleFix":"// before\nawait RestImporter.init(data, \"openapi3\") // throws\n// after\nawait RestImporter.init(data, \"openapi3.0\")\n// or auto-detect:\nawait RestImporter.init(data)","handlingStrategy":"validation","validationCode":"const SUPPORTED_TYPES = [\"openapi2.0\", \"openapi3.0\", \"curl\"] as const\ntype ImportType = typeof SUPPORTED_TYPES[number]\nconst isSupportedType = (t: string): t is ImportType =>\n  (SUPPORTED_TYPES as readonly string[]).includes(t.toLowerCase())","typeGuard":"const isImportType = (t: string): t is \"openapi2.0\" | \"openapi3.0\" | \"curl\" =>\n  [\"openapi2.0\", \"openapi3.0\", \"curl\"].includes(t)","tryCatchPattern":"null","preventionTips":["Only pass types from the server's exact key set (lowercase, versioned like 'openapi3.0')","Omit the type parameter to rely on auto-detection when unsure","Map your client-side type labels to the server keys in one shared constant"],"tags":["validation","bad-request","import"],"backgroundTag":"unsupported-import-format","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}