{"record":{"id":"5896cf78116b8c8b","repo":"apache/druid","slug":"cannot-get-map-view","errorCode":null,"errorMessage":"Cannot get map view","messagePattern":"Cannot get map view","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"extensions-core/lookups-cached-single/src/main/java/org/apache/druid/server/lookup/PollingLookup.java","lineNumber":171,"sourceCode":"      return cache.getKeys(value);\n    }\n    finally {\n      if (cache != null) {\n        cacheRefKeeper.doneWithIt();\n      }\n    }\n  }\n\n  @Override\n  public boolean supportsAsMap()\n  {\n    return false;\n  }\n\n  @Override\n  public Map<String, String> asMap()\n  {\n    throw new UnsupportedOperationException(\"Cannot get map view\");\n  }\n\n  @Override\n  public byte[] getCacheKey()\n  {\n    return LookupExtractionModule.getRandomCacheKey();\n  }\n\n  private Runnable pollAndSwap()\n  {\n    return new Runnable()\n    {\n      @Override\n      public void run()\n      {\n        LOGGER.debug(\"Polling and swapping of PollingLookup [%s]\", id);\n        CacheRefKeeper newCacheKeeper = new CacheRefKeeper(cacheFactory.makeOf(dataFetcher.fetchAll()));\n        CacheRefKeeper oldCacheKeeper = refOfCacheKeeper.getAndSet(newCacheKeeper);","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/lookups-cached-single/src/main/java/org/apache/druid/server/lookup/PollingLookup.java#L153-L189","documentation":"PollingLookup.asMap() is unimplemented: a polling lookup is backed by an external data source that is periodically reloaded, so it deliberately refuses to expose a full map view. Any code that requests the whole lookup contents as a Map hits this UnsupportedOperationException.","triggerScenarios":"Invoking asMap() on a polling (cached-single) lookup — e.g. code paths that dump lookup contents, bulk-export lookups, or the lookup introspection API.","commonSituations":"Trying to dump lookup contents via tooling or the /druid/coordinator/v1/lookups introspection paths; code written generically over MapLookupExtractionFnResolvingLookup that assumes asMap() always works.","solutions":["Read the underlying data source (CSV/JSON/URL feed) directly to enumerate entries","Use a map-backed lookup implementation if a full map view is required","Guard generic code with lookup.canIterate()/supportsAsMap checks before calling asMap()"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"boolean canExportAsMap(LookupExtractor l) { return !(l instanceof PollingLookup); }","tryCatchPattern":"try { return lookup.asMap(); } catch (UnsupportedOperationException e) { return exportFromDataSource(lookup); }","preventionTips":["Never assume all LookupExtractor implementations support asMap()","Check the lookup type before bulk export; polling lookups must be read from their data source","Prefer LookupExtractor.get()/unapply() iteration for generic code"],"tags":["unsupported-operation","lookup"],"backgroundTag":"unsupported-operation","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}