OtterMind/Chat2DB · error · BusinessException

ai.model.config.notFound

ai.model.config.notFound

Error message

ai.model.config.notFound

What it means

Thrown by AiModelConfigServiceImpl.resolveRuntimeModel when a modelConfigId was provided (not preset-prefixed) and resolved to an id, but findById returned null against the current user's config list. The referenced config does not exist for this user. The i18n message resolves to 'AI model configuration does not exist.'

Source

Thrown at chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/ai/AiModelConfigServiceImpl.java:245

        return ModelConfigTestResponse.failure(null, null,
                "Connection test currently supports OpenAI-compatible models only.");
    }

    public synchronized AiRuntimeModel resolveRuntimeModel(AiChatRuntimeResolveRequest request) {
        Long userId = identityService.currentUserId();
        AiModelConfig baseConfig = null;
        boolean systemPreset = false;
        if (StringUtils.isNotBlank(request.getModelConfigId())) {
            String modelConfigId = request.getModelConfigId().trim();
            if (modelConfigId.startsWith(PRESET_VALUE_PREFIX)) {
                throw new BusinessException(ERROR_MODEL_CONFIG_REQUIRED);
            } else {
                String resolvedId = modelConfigId.startsWith(CONFIG_VALUE_PREFIX)
                        ? modelConfigId.substring(CONFIG_VALUE_PREFIX.length())
                        : modelConfigId;
                baseConfig = findById(userConfigMap.getOrDefault(userId, new ArrayList<>()), resolvedId);
                if (Objects.isNull(baseConfig)) {
                    throw new BusinessException("ai.model.config.notFound");
                }
            }
        } else if (StringUtils.isNotBlank(request.getProvider()) && StringUtils.isNotBlank(request.getModel())) {
            baseConfig = new AiModelConfig();
            baseConfig.setProvider(request.getProvider());
            baseConfig.setModel(request.getModel());
            baseConfig.setApiKey(request.getApiKey());
            baseConfig.setBaseUrl(request.getBaseUrl());
            baseConfig.setProjectId(request.getProjectId());
            baseConfig.setLocation(request.getLocation());
            baseConfig.setTemperature(request.getTemperature());
            baseConfig.setMaxTokens(request.getMaxTokens());
            systemPreset = isPresetModel(request.getProvider(), request.getModel())
                    && StringUtils.isBlank(request.getApiKey())
                    && StringUtils.isBlank(request.getBaseUrl())
                    && StringUtils.isBlank(request.getProjectId())
                    && StringUtils.isBlank(request.getLocation());
            if (systemPreset) {

View on GitHub (pinned to 5ee1e990e7)

Solutions

  1. Refresh the model config list for the current user and use a valid 'config:<id>' (or default-flagged config).
  2. If the config was deleted, create a new one and update the frontend's selected id.
  3. Verify the authenticated user matches the config's userId; configs are user-scoped.

Example fix

// before
resolve.setModelConfigId("config:99"); // 99 was deleted

// after
List<AiModelConfig> mine = configService.listMine();
AiModelConfig active = mine.stream().filter(AiModelConfig::getDefaultConfig).findFirst()
    .orElseThrow(() -> new IllegalStateException("no config"));
resolve.setModelConfigId("config:" + active.getId());
Defensive patterns

Strategy: validation

Validate before calling

List<AiModelConfig> mine = configService.listMine();
String id = stripConfigPrefix(request.getModelConfigId());
if (mine.stream().noneMatch(c -> Objects.equals(String.valueOf(c.getId()), id))) {
    return ResponseEntity.badRequest().body("config not found for this user");
}

Try / catch

try {
    service.resolveRuntimeModel(request);
} catch (BusinessException e) {
    if ("ai.model.config.notFound".equals(e.getCode())) {
        return ResponseEntity.status(404).body("model config does not exist");
    }
    throw e;
}

Prevention

When it happens

Trigger: modelConfigId (after stripping the optional 'config:' prefix) does not match any AiModelConfig id in userConfigMap for the current identityService user. Caused by a deleted config, a config owned by another user, an id typo, or stale frontend state referencing a removed config.

Common situations: User deleted a saved model config then sent a chat request still referencing its id; the id belongs to a different user account; the in-memory userConfigMap is keyed by userId and the caller's identity resolves to a user with no such config; an id mismatch after migration.

Related errors


AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14). Data as JSON: /api/errors/e57990a0e1721b26. Report an issue: GitHub.