ThreeMammals/Ocelot · error · ConfigurationRepositoryException
ConfigurationRepositoryException(config.Errors)
Error message
ConfigurationRepositoryException(config.Errors)
What it means
FileAndInternalConfigurationSetter.SetAsync creates the internal configuration from the FileConfiguration via IConfigurationCreator; if the creation result IsError, it throws ConfigurationRepositoryException carrying those errors. This aggregates all internal config validation/creation failures when setting the file-based configuration.
Solutions
- Inspect the ConfigurationRepositoryException.Errors collection — each lists the specific config problem.
- Validate ocelot.json against the Ocelot schema and the current version's validator rules.
- Fix the offending route/aggregate fields reported in the errors (e.g. add missing ServiceName/DownstreamHostAndPorts).
- Check for breaking config changes if this appeared after upgrading Ocelot.
- Add a config validation step (IConfigurationValidator) before calling SetAsync in startup.
Example fix
// before
var config = await _configCreator.Create(configuration);
if (config.IsError)
throw new ConfigurationRepositoryException(config.Errors);
// after (caller-side guard)
var validation = await configValidator.Validate(configuration);
if (!validation.IsError) await setter.SetAsync(configuration); Defensive patterns
Strategy: validation
Validate before calling
var result = await configurationValidator.Validate(fileConfiguration);
if (result.IsError)
{
foreach (var e in result.Errors) Error(e.ToString());
throw new InvalidOperationException("Invalid ocelot configuration, see errors above");
} Try / catch
try { await setter.SetAsync(fileConfiguration, ct); }
catch (ConfigurationRepositoryException ex)
{
foreach (var e in ex.Errors) Error($"Config error: {e}");
throw;
} Prevention
- Validate ocelot.json against the Ocelot schema before deployment
- Log the Errors collection — it names each specific config problem
- Re-validate configuration after Ocelot upgrades for breaking changes
- Cover route/aggregates definitions with startup integration tests
When it happens
Trigger: IInternalConfigurationCreator.Create returns an Error result: invalid route/aggregates definitions, duplicate route keys, unsupported QoS/timeout options, downstream/upstream scheme problems, or validation errors from the config validator.
Common situations: Malformed ocelot.json routes (missing required fields, conflicting properties); invalid aggregation configuration; unsupported combinations after an Ocelot version upgrade; JSON with wrong types for options.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- The ' ' value doesn't include any digits, so it cannot be…
- The ' ' timespan cannot be converted to TimeSpan due to an…
AI-assisted analysis of ThreeMammals/Ocelot@d1f22d9304 (2026-09-12).
Data as JSON: /api/errors/09dba7b5731abb63.
Report an issue: GitHub.
Appendix: source
Thrown at src/Configuration/Repository/FileAndInternalConfigurationSetter.cs:37
private readonly IFileConfigurationRepository _repo;
public FileAndInternalConfigurationSetter(
IInternalConfigurationRepository configRepo,
IInternalConfigurationCreator configCreator,
IFileConfigurationRepository repo)
{
_internalConfigRepo = configRepo;
_configCreator = configCreator;
_repo = repo;
}
public async Task SetAsync(FileConfiguration configuration, CancellationToken cancellationToken = default)
{
await _repo.SetAsync(configuration, cancellationToken);
var config = await _configCreator.Create(configuration);
if (config.IsError)
throw new ConfigurationRepositoryException(config.Errors);
_internalConfigRepo.AddOrReplace(config.Data);
}
}
View on GitHub (pinned to d1f22d9304)