Skip to content

[BUG] NullReferenceException in LucidaIndexer.Test() when adding Lucida indexer #135

@flowcool

Description

@flowcool

Tubifarry Version

v2.0.4.1-develop

Lidarr Version

v3.1.2.4914

Operating System

Docker

Bug Description

When attempting to add a new Lucida indexer in Lidarr, LucidaIndexer.Test() throws a NullReferenceException after FlareSolverr successfully solves the Cloudflare challenge. The indexer cannot be saved.

Steps to Reproduce

  1. Configure FlareSolverr notification in Lidarr (pointing to a working solver)
  2. Add a new Lucida indexer with baseUrl: https://lucida.to
  3. FlareSolverr solves the Cloudflare challenge successfully
  4. After retry with cf_clearance cookie, the Lucida API returns service data
  5. LucidaIndexer.Test() crashes with NullReferenceException

Expected Behavior

adding indexer without issue

Trace Log Files

Stack Trace

System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
   at Tubifarry.Indexers.Lucida.LucidaIndexer.Test(List`1 failures)

Log Sequence

[Info] Protection challenge detected for lucida.to (attempt 1/3) - Status: Forbidden
[Info] Successfully solved challenge for lucida.to
[Info] Challenge solved, retrying with 1 cookies: [cf_clearance]
[Error] NullReferenceException in LucidaIndexer.Test()

Without FlareSolverr: all /api/countries?service=X return 403 → "No services available" (validation failure, no crash). The NullRef only occurs when the solver succeeds and actual service data is returned.

Root Cause Analysis

The .SelectMany().Any() LINQ chain in LucidaIndexer.Test() iterates services and their sub-collections (likely countries arrays). One service returns a null collection instead of an empty array, causing SelectMany to crash.

Suggested Fix

// Instead of:
services.SelectMany(s => s.Countries).Any(...)

// Use:
services.Where(s => s.Countries != null).SelectMany(s => s.Countries).Any(...)
// or
services.SelectMany(s => s.Countries ?? Enumerable.Empty<Country>()).Any(...)

Log Checklist

  • I have enabled Trace logging in Lidarr before reproducing the issue

Screenshots

Screenshots

Additional Context

Error in Lidarr UI

Validation failed:
-- BaseUrl: No services available from Lucida instance

Environment

  • Lidarr: v3.1.2.4914 (nightly)
  • Tubifarry: v2.0.4.1-develop
  • FlareSolverr: simple-cloudflare-solver (port 8000)
  • OS: Synology DSM 7 (Docker)

Notes

  • The indexer was working earlier the same day (downloads at 06:19 UTC). The issue may be intermittent depending on the Lucida API response structure.
  • A previously existing Lucida indexer was deleted and cannot be re-added.

Metadata

Metadata

Assignees

No one assigned

    Labels

    WebClientClients or Indexer that are based on web servicesbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions