alibaba/nacos · warning · NacosApiException

RESOURCE_NOT_FOUND

RESOURCE_NOT_FOUND

Error message

AI resource import plugin not found: {}

What it means

Thrown by AiResourceImportPluginManager.resolveBuilder() when no loaded AI resource import builder is registered under the requested pluginName (the sourceId). The manager looks up builders discovered via SPI (NacosServiceLoader.load(AiResourceImportServiceBuilder.class)); a miss means the source id does not correspond to any discovered plugin. Mapped to RESOURCE_NOT_FOUND with a NOT_FOUND top-level code.

Source

Thrown at ai/src/main/java/com/alibaba/nacos/ai/importer/manager/AiResourceImportPluginManager.java:130

            result.add(toSourceInfo(each));
        }
        return result;
    }
    
    /**
     * Resolve an enabled managed builder.
     *
     * @param pluginName managed plugin name and source id
     * @param resourceType expected resource type
     * @return resolved builder
     * @throws NacosException if routing fails
     */
    public AiResourceImportServiceBuilder resolveBuilder(String pluginName, String resourceType)
        throws NacosException {
        requireModuleEnabled();
        AiResourceImportServiceBuilder result = getLoadedPlugins().get(pluginName);
        if (result == null) {
            throw new NacosApiException(NacosException.NOT_FOUND,
                ErrorCode.RESOURCE_NOT_FOUND,
                "AI resource import plugin not found: " + pluginName);
        }
        if (!isPluginEnabled(pluginName)) {
            throw new NacosApiException(NacosException.INVALID_PARAM,
                ErrorCode.PARAMETER_VALIDATE_ERROR,
                "AI resource import plugin is disabled: " + pluginName);
        }
        if (!supportsResourceType(result, resourceType)) {
            throw new NacosApiException(NacosException.INVALID_PARAM,
                ErrorCode.PARAMETER_VALIDATE_ERROR,
                "AI resource import plugin does not support resource type: " + resourceType);
        }
        return result;
    }
    
    private Map<String, AiResourceImportServiceBuilder> getLoadedPlugins() {
        Map<String, AiResourceImportServiceBuilder> result = builders;

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Call the list sources endpoint first and use a sourceId returned there (it equals builder.pluginName()).
  2. Verify the expected plugin jar is deployed and its SPI descriptor (META-INF/services/com.alibaba.nacos.plugin.ai.importer.spi.AiResourceImportServiceBuilder) lists the implementation.
  3. Check server startup logs to confirm the builder was discovered by NacosServiceLoader.

Example fix

// before
request.setSourceId("mcphub"); // wrong id

// after: discover valid ids first
List<AiResourceImportSourceInfo> sources = manager.listSources(null);
String id = sources.stream().filter(s -> s.getDisplayName().contains("MCP Hub"))
    .map(AiResourceImportSourceInfo::getSourceId).findFirst().orElseThrow();
request.setSourceId(id);
Defensive patterns

Strategy: validation

Validate before calling

List<AiResourceImportSourceInfo> sources = pluginManager.listSourceInfos(null);
Set<String> validIds = sources.stream()
    .map(AiResourceImportSourceInfo::getSourceId)
    .collect(Collectors.toSet());
if (!validIds.contains(request.getSourceId())) {
    throw new IllegalArgumentException(
        "Unknown sourceId '" + request.getSourceId() + "'. Valid: " + validIds);
}

Prevention

When it happens

Trigger: An import search/validate/execute request whose sourceId does not match any builder.pluginName() in the loaded plugin map. Also fires when the plugin map has not been populated (loadPlugins never triggered) and getLoadedPlugins() returns empty.

Common situations: Typo in the sourceId passed by the client; the plugin jar is not on the server classpath or its SPI metadata file is missing under META-INF/services; requesting a source that belongs to a different Nacos deployment; calling import before loadPlugins() has run.

Related errors


AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14). Data as JSON: /api/errors/d1b3660a30d919e4. Report an issue: GitHub.