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

  1. Start with a fresh 19.0+ Ultimate instance with package_metadata_sync_using_labels enabled.
  2. Ensure there is no persisted advisory checkpoint:
    PackageMetadata::Checkpoint.where(data_type: 'advisories').delete_all
  3. Trigger the worker:
    PackageMetadata::AdvisoriesSyncWorker.new.perform
  4. Before this change the worker fails with NoMethodError: undefined method '>=' for nil.
  5. After this change the worker takes the listobjects_blank_checkpoint path 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-sequence checkpoint.
  • Verifies the nil-sequence path no longer raises.
  • Verifies the listobjects_blank_checkpoint fallback still fires and the internal event is tracked.
Edited by Igor Frenkel

Merge request reports

Loading