apolloconfig/apollo · warning · NotFoundException
server config not found for key:%s
Error message
server config not found for key:%s
What it means
Thrown as a NotFoundException by ServerConfigService.deletePortalDBConfig() when serverConfigRepository.findByKey(key) returns null for the given key. This means no server configuration entry exists in the portal database with that key, so there is nothing to soft-delete (set deleted=true). The check is a precondition guard before the delete operation.
Source
Thrown at apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ServerConfigService.java:84
BeanUtils.copyEntityProperties(serverConfig, storedConfig);
storedConfig.setDataChangeLastModifiedBy(modifiedBy);
return serverConfigRepository.save(storedConfig);
}
@Transactional
public ServerConfig createOrUpdateConfigDBConfig(Env env, ServerConfig serverConfig,
String modifiedBy) {
serverConfig.setDataChangeCreatedBy(modifiedBy);
serverConfig.setDataChangeLastModifiedBy(modifiedBy);
return serverConfigAPI.createOrUpdateConfigDBConfig(env, serverConfig);
}
@Transactional
public void deletePortalDBConfig(String key, String modifiedBy) {
ServerConfig storedConfig = serverConfigRepository.findByKey(key);
if (Objects.isNull(storedConfig)) {
throw new NotFoundException("server config not found for key:%s", key);
}
storedConfig.setDeleted(true);
storedConfig.setDataChangeLastModifiedBy(modifiedBy);
serverConfigRepository.save(storedConfig);
}
public void deleteConfigDBConfig(Env env, String key, String cluster, String modifiedBy) {
serverConfigAPI.deleteConfigDBConfig(env, key, cluster, modifiedBy);
}
}
View on GitHub (pinned to d95fc18d11)
Solutions
- Verify the config key exists in the portal server config table before calling delete.
- Check if the config was already soft-deleted (deleted=true) in a previous operation.
- If deleting a config-service-level config (not portal DB), use deleteConfigDBConfig(env, key, cluster, modifiedBy) instead.
- List all server configs via the portal API/UI to confirm the exact key spelling.
Defensive patterns
Strategy: validation
Validate before calling
// Verify the server config key exists before deleting
ServerConfig config = serverConfigRepository.findByKey(key);
if (config == null) {
// already deleted or never existed - treat as no-op or inform user
log.warn("Server config not found for key: {}, nothing to delete", key);
return;
} Try / catch
try {
serverConfigService.deletePortalDBConfig(key, modifiedBy);
} catch (NotFoundException e) {
if (e.getMessage().contains("server config not found")) {
log.warn("Config key '{}' not found, may have been already deleted", key);
return; // treat as idempotent success
}
throw e;
} Prevention
- List server configs before attempting delete to confirm the key exists.
- Handle not-found gracefully — a missing config may already be deleted.
- Distinguish portal DB configs from env-specific config DB configs.
When it happens
Trigger: Calling deletePortalDBConfig with a key that does not exist in the portal's ServerConfig repository. The findByKey query returns null, and the NotFoundException is thrown before any modification.
Common situations: Typo in the config key; the config was already deleted (soft-deleted) in a previous operation; attempting to delete a config that only exists in a specific env's config DB (not the portal DB); key case sensitivity mismatch.
Related errors
- server config not found for key:%s, cluster:%s
- ConsumerApp not exist
- ServerConfig can not be null
- ServerConfig.Key cannot be blank
- ServerConfig.Value cannot be blank
AI-assisted analysis of apolloconfig/apollo@d95fc18d11 (2026-08-14).
Data as JSON: /api/errors/60a5ae73ff19f73f.
Report an issue: GitHub.