alibaba/spring-ai-alibaba · warning

未检测到模型配置文件: ,以空配置启动(可稍后创建该文件触发热加载)

Error message

未检测到模型配置文件: {},以空配置启动(可稍后创建该文件触发热加载)

What it means

FileModelConfigRepository loads model configuration from a local file at startup (afterPropertiesSet -> loadFileOrFail). If the configured configPath does not exist, it logs this warning and starts with an empty, unmodifiable snapshot instead of failing — the file can be created later to trigger hot reload. This is a warning-level diagnostic, not a thrown exception.

Solutions

  1. Create the model config file at the logged path (this.configPath) — hot reload will pick it up without restart.
  2. Point the repository's config-path property to the actual location of your existing model config file.
  3. If running in a container, mount or bake the config file into the image at the expected path.
  4. If starting empty is intentional, no action is needed — treat the log line as informational.

Example fix

// before (application.yml)
spring.ai.alibaba.admin.model-config.path: ./models.json   // file absent
// after
spring.ai.alibaba.admin.model-config.path: /etc/app/model-config.json   // file exists there
Defensive patterns

Strategy: validation

Validate before calling

Path p = Path.of(configPathProperty);
if (!Files.exists(p)) { log.warn("model config file absent: {} — create it or fix the path before expecting models", p); }

Try / catch

// The library itself handles the absence (warn + empty snapshot); only guard downstream reads:
ModelConfigDO cfg = repository.findById(id);
if (cfg == null) { log.warn("no model config {} — file was missing at startup?", id); }

Prevention

When it happens

Trigger: Application startup where spring-ai-alibaba-admin-server-start's model config file property points to a path that does not exist on disk (file never created, wrong path configured, or the app runs in a fresh container/volume without the file mounted).

Common situations: First deployment before any model config was authored; Docker/Kubernetes volume without the config file; relative vs absolute path confusion causing the app to look in the working directory; renamed config file after an upgrade.

Related errors


AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09). Data as JSON: /api/errors/05c9539e721cb0db. Report an issue: GitHub.

Appendix: source

Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/repository/impl/FileModelConfigRepository.java:82

        loadFileOrFail();
        startWatchService();
    }
    
    private void resolveConfigPath() {
        String configured = environment.getProperty(ENV_KEY);
        if (configured != null && !configured.isBlank()) {
            this.configPath = Paths.get(configured).toAbsolutePath().normalize();
        } else {
            this.configPath = Paths.get("./" + DEFAULT_FILE).toAbsolutePath().normalize();
        }
        log.info("模型配置文件路径: {}", this.configPath);
    }
    
    private void loadFileOrFail() {
        try {
            if (!Files.exists(this.configPath)) {
                this.snapshot.set(Collections.unmodifiableMap(new HashMap<>()));
                log.warn("未检测到模型配置文件: {},以空配置启动(可稍后创建该文件触发热加载)", this.configPath);
                return;
            }
            Map<Long, ModelConfigDO> data = loadFromFile(this.configPath);
            this.snapshot.set(Collections.unmodifiableMap(data));
            log.info("模型配置加载成功,数量: {}", data.size());
        } catch (Exception e) {
            // 允许空配置启动:若解析失败,仍然以空配置启动
            this.snapshot.set(Collections.unmodifiableMap(new HashMap<>()));
            log.error("启动时加载模型配置失败,将以空配置启动: {}", e.getMessage(), e);
        }
    }
    
    private Map<Long, ModelConfigDO> loadFromFile(Path file) throws IOException {
        // 此方法假定调用方已判断文件存在
        byte[] bytes = Files.readAllBytes(file);
        YamlRoot root = yamlMapper.readValue(bytes, YamlRoot.class);
        if (root == null || root.models == null) {
            return new HashMap<>();

View on GitHub (pinned to f82da0b50f)