From a4203cf392b68e5276e161685627cb6ac81f6403 Mon Sep 17 00:00:00 2001 From: John Lambert Date: Mon, 13 Jan 2025 10:03:40 -0500 Subject: [PATCH] Don't crash if retrieving a corpora with a blank language code (#600) --- .../src/Serval.DataFiles/Controllers/CorporaController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Serval/src/Serval.DataFiles/Controllers/CorporaController.cs b/src/Serval/src/Serval.DataFiles/Controllers/CorporaController.cs index 7c9028a0..29a72170 100644 --- a/src/Serval/src/Serval.DataFiles/Controllers/CorporaController.cs +++ b/src/Serval/src/Serval.DataFiles/Controllers/CorporaController.cs @@ -81,6 +81,8 @@ public async Task> CreateAsync( CancellationToken cancellationToken ) { + if (corpusConfig.Language.Length == 0) + return BadRequest("Corpus must have a language."); Corpus corpus = await MapAsync(corpusConfig, idGenerator.GenerateId(), cancellationToken); await _corpusService.CreateAsync(corpus, cancellationToken); CorpusDto dto = Map(corpus); @@ -157,8 +159,6 @@ private async Task AuthorizeAsync(string id, CancellationToken cancellationToken private async Task MapAsync(CorpusConfigDto corpusConfig, string id, CancellationToken cancellationToken) { - if (corpusConfig.Language.Length == 0) - throw new InvalidOperationException("Corpus must have a language."); return new Corpus { Id = id,