{"record":{"id":"973c457b6a4c9c12","repo":"Budibase/budibase","slug":"selected-endpoint-could-not-be-imported","errorCode":null,"errorMessage":"Selected endpoint could not be imported","messagePattern":"Selected endpoint could not be imported","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/server/src/api/controllers/query/import/index.ts","lineNumber":236,"sourceCode":"  getInfo = () => this.source.getInfo()\n\n  importQueries = async (\n    datasourceId: string,\n    selectedEndpointId?: string\n  ): Promise<ImportResult> => {\n    const filterIds = selectedEndpointId\n      ? new Set<string>([selectedEndpointId])\n      : undefined\n    const staticVariables =\n      await this.getDatasourceStaticVariables(datasourceId)\n    // construct the queries\n    let queries = this.source.getQueries(datasourceId, {\n      filterIds,\n      staticVariables,\n    })\n\n    if (filterIds && queries.length === 0) {\n      throw new Error(\"Selected endpoint could not be imported\")\n    }\n\n    // validate queries\n    const errorQueries: Query[] = []\n    const schema = queryValidation()\n    queries = queries\n      .filter(query => {\n        const validation = schema.validate(query)\n        if (validation.error) {\n          errorQueries.push(query)\n          return false\n        }\n        return true\n      })\n      .map(query => {\n        query._id = generateQueryID(query.datasourceId)\n        return query\n      })","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/api/controllers/query/import/index.ts#L218-L254","documentation":"During import of a REST definition, when a filterIds set is supplied only those endpoints are returned by source.getQueries. If filtering leaves zero queries, the importer throws 'Selected endpoint could not be imported' — meaning none of the selected endpoints exist in or survived parsing of the source document.","triggerScenarios":"Calling importQueries (or the importer flow) with filterIds referencing endpoint IDs that are not present in the loaded spec — typically after the spec changed between the listing step and the import step, or IDs were built with a different serialization.","commonSituations":"The UI cached the endpoint list, the spec was updated/renamed on the server, then the user imported; importing selected endpoints from a re-fetched spec whose operation paths changed; hand-crafted filterIds that never matched.","solutions":["Re-fetch the import info/endpoints from the current spec and re-select before importing","Log and compare the filterIds against the endpoints returned by getImportInfo to find stale IDs","Fix your code so filterIds are derived from the same source instance that performs the import"],"exampleFix":"// before\nconst { endpoints } = await getImportInfo(oldInput) // stale\nawait importer.importQueries(dsId, { filterIds: new Set(oldIds) })\n// after\nconst { endpoints } = await getImportInfo(currentInput)\nconst filterIds = new Set(endpoints.map(e => e.id))\nawait importer.importQueries(dsId, { filterIds })","handlingStrategy":"validation","validationCode":"const info = await getImportInfo(input)\nconst validIds = new Set(info.endpoints.map(e => e.id))\nconst stale = [...filterIds].filter(id => !validIds.has(id))\nif (stale.length) throw new Error(`Selected endpoints no longer exist: ${stale.join(\", \")}`)","typeGuard":"null","tryCatchPattern":"try {\n  await importer.importQueries(datasourceId, { filterIds })\n} catch (e) {\n  if (String(e?.message).includes(\"Selected endpoint could not be imported\")) {\n    // refresh endpoint list and ask user to re-select\n  }\n  throw e\n}","preventionTips":["Always derive filterIds from a getImportInfo call on the same spec version you import from","Invalidate cached endpoint lists whenever the spec changes","Don't persist endpoint IDs across spec re-imports without re-validating them"],"tags":["validation","openapi","stale-data","import"],"backgroundTag":"stale-resource-reference","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}