Fix nil error when checking checkpoints that are not fully instantiated
What does this MR do and why?
Makes the GCP package metadata connector nil-safe when the label-based sync path runs against a checkpoint that has no sequence value.
On a fresh 19.0+ self-managed Ultimate instance, PackageMetadata::AdvisoriesSyncWorker and PackageMetadata::LicensesSyncWorker raise NoMethodError: undefined method '>=' for nil. SyncService obtains the checkpoint via PackageMetadata::Checkpoint.with_path_components, which uses find_or_initialize_by and returns an unpersisted record with sequence: nil. The connector's existing checkpoint.blank? guard is false for that object, so the label path proceeds and blows up before listObjects is reached.
The result on affected instances is that advisory and license data are never ingested and Dependency Scanning v2 fails at vuln-scan with advisory data is missing from your GitLab instance.
The fix extends the existing "blank checkpoint" guard in data_after so an unpersisted checkpoint with a nil sequence also takes the listobjects_blank_checkpoint fallback and completes the initial sync. package_metadata_sync_using_labels is default-enabled since 19.0, so today the only workaround is disabling the flag and re-running the worker.
Changelog: fixed
References
Closes #603943 (closed)
Screenshots or screen recordings
N/A. Backend-only change.
How to set up and validate locally
- Start with a fresh 19.0+ Ultimate instance with
package_metadata_sync_using_labelsenabled. - Ensure there is no persisted advisory checkpoint:
PackageMetadata::Checkpoint.where(data_type: 'advisories').delete_all - Trigger the worker:
PackageMetadata::AdvisoriesSyncWorker.new.perform - Before this change the worker fails with
NoMethodError: undefined method '>=' for nil. - After this change the worker takes the
listobjects_blank_checkpointpath and ingests advisory data.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. Fix-specific items:
- Reproduces the failure with an added spec covering the unpersisted, nil-
sequencecheckpoint. - Verifies the nil-
sequencepath no longer raises. - Verifies the
listobjects_blank_checkpointfallback still fires and the internal event is tracked.