fix: add null check for non-existent program in GetProgram (#16858)

fix: add null check for non-existent program in GetProgram
This commit is contained in:
Bruno Ferreira
2026-05-17 09:01:39 -03:00
committed by GitHub
parent ed3c62b66e
commit 2f8bf92fb8
2 changed files with 14 additions and 1 deletions

View File

@@ -744,10 +744,12 @@ public class LiveTvController : BaseJellyfinApiController
/// <param name="programId">Program id.</param>
/// <param name="userId">Optional. Attach user data.</param>
/// <response code="200">Program returned.</response>
/// <response code="404">Program not found.</response>
/// <returns>An <see cref="OkResult"/> containing the livetv program.</returns>
[HttpGet("Programs/{programId}")]
[Authorize(Policy = Policies.LiveTvAccess)]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult<BaseItemDto>> GetProgram(
[FromRoute, Required] string programId,
[FromQuery] Guid? userId)
@@ -756,8 +758,14 @@ public class LiveTvController : BaseJellyfinApiController
var user = userId.IsNullOrEmpty()
? null
: _userManager.GetUserById(userId.Value);
var result = await _liveTvManager.GetProgram(programId, CancellationToken.None, user).ConfigureAwait(false);
return await _liveTvManager.GetProgram(programId, CancellationToken.None, user).ConfigureAwait(false);
if (result is null)
{
return NotFound();
}
return Ok(result);
}
/// <summary>

View File

@@ -178,6 +178,11 @@ namespace Jellyfin.LiveTv
{
var program = _libraryManager.GetItemById(id);
if (program is null)
{
return null;
}
var dto = _dtoService.GetBaseItemDto(program, new DtoOptions(), user);
var list = new List<(BaseItemDto ItemDto, string ExternalId, string ExternalSeriesId)>