✨ Quality: Potential null reference when accessing Author property in AuthorCatalogFetchResult#441
Conversation
…authorcatalogfetchresult The AuthorCatalogFetchResult.Author property is initialized with 'new()' but the AuthorLookupItem type is not shown. If AuthorLookupItem has non-nullable reference types that aren't properly initialized, accessing them could cause null reference exceptions. This is a data model that flows through the application and could crash at runtime. Affected files: IAuthorCatalogService.cs Signed-off-by: halinhtvn3a <77691576+halinhtvn3a@users.noreply.github.com>
|
Thanks a lot for the contribution, and for taking the time to look through this area. I reviewed the change closely, and I don’t think we should take this one as-is. The main reason is that this change makes More importantly, the current contract in this area is effectively:
That pattern is relied on by existing callers, and the service implementation already follows it. So making In other words, this looks more like a static-analysis-driven type loosening than a fix for an actual bug. If we ever find a real path where Really appreciate the submission and the effort here either way. Please keep them coming. |
|
Closing this one out for now since we don't want to weaken the AuthorCatalogFetchResult contract without evidence of a real null-path bug. |
✨ Code Quality
Problem
The AuthorCatalogFetchResult.Author property is initialized with 'new()' but the AuthorLookupItem type is not shown. If AuthorLookupItem has non-nullable reference types that aren't properly initialized, accessing them could cause null reference exceptions. This is a data model that flows through the application and could crash at runtime.
Severity:
mediumFile:
listenarr.api/Services/IAuthorCatalogService.csSolution
// Option 1: Make Author nullable if it can be null
public AuthorLookupItem? Author { get; set; }
// Option 2: Initialize with all required properties if AuthorLookupItem is defined elsewhere
// Ensure AuthorLookupItem constructor initializes all non-nullable properties
Changes
listenarr.api/Services/IAuthorCatalogService.cs(modified)Testing
🤖 About this PR
This pull request was generated by ContribAI, an AI agent
that helps improve open source projects. The change was:
If you have questions or feedback about this PR, please comment below.
We appreciate your time reviewing this contribution!
Closes #440