fix(scraper): prevent nil pointer dereference in scrapeScene

When scrapeScene finds no results, ret remains nil and is passed to
processSceneRelationships, which unconditionally dereferences it at
line 89 (ret.Performers = ...), causing a panic.

Initialize ret to an empty ScrapedScene so processSceneRelationships
always has a valid pointer. This also preserves the intent of #3953:
returning a scene with only relationship fields set when scraped
non-relationship data is absent.

Fixes panic: runtime error: invalid memory address or nil pointer
dereference at pkg/scraper/mapped.go:89 in processSceneRelationships
This commit is contained in:
Marco 2026-04-23 00:16:29 +02:00
parent 22d2dbc46b
commit 820f354ed2

View file

@ -184,7 +184,10 @@ func (s mappedScraper) scrapeScene(ctx context.Context, q mappedQuery) (*models.
logger.Debug(`Processing scene:`)
results := sceneMap.process(ctx, q, s.Common, urlsIsMulti)
var ret *models.ScrapedScene
// Initialize ret to a non-nil empty scene so that processSceneRelationships
// can safely populate relationship fields even when no direct results were found.
// This preserves the intent of #3953: returning a scene with only relationships.
ret := &models.ScrapedScene{}
if len(results) > 0 {
ret = results[0].scrapedScene()
}