Guard against nil source project in GitDeduplicationService

What does this MR do and why?

Adds a nil guard to Projects::GitDeduplicationService#pool_can_fetch_from_source?, which previously called pool_repository.source_project.repository without checking for a nil source_project.

Pool repositories can lose their source project: the pool_repositories.source_project_id foreign key is ON DELETE SET NULL, so deleting a source project leaves the pool with a nil source. If this method were reached with such a pool, it would raise NoMethodError.

This is currently unreachable through the only production caller (Projects::GitGarbageCollectWorker → GitDeduplicationService#execute), because source_project? short-circuits to false when source_project is nil. This change is defensive hardening against future callers or reordering, not a fix for an active crash.

References

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Emma Park

Merge request reports

Loading
Loading