Skip to content

Commit

Permalink
Don't crash if retrieving a corpora with a blank language code (#600)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnml1135 authored Jan 13, 2025
1 parent f45b102 commit a4203cf
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ public async Task<ActionResult<CorpusDto>> 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);
Expand Down Expand Up @@ -157,8 +159,6 @@ private async Task AuthorizeAsync(string id, CancellationToken cancellationToken

private async Task<Corpus> 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,
Expand Down

0 comments on commit a4203cf

Please sign in to comment.