Skip to content

Geo fix: ActiveRecord::StatementInvalid: PG::UndefinedColumn when querying reverification count

What does this MR do?

Fixes a PG::UndefinedColumn error in Geo::ReverificationBatchWorker that was causing the worker to fail on staging-ref and local GDK environments.

Problem

The Geo::ReverificationBatchWorker was failing with ActiveRecord::StatementInvalid: PG::UndefinedColumn errors when querying reverification counts for models with separate state tables.

Root Cause: The needs_reverification scope was attempting to query verified_at directly, but this column exists on the state table (e.g., upload_state) rather than the parent model table (e.g., upload). The scope verification_succeeded returns parent models, creating a mismatch when Rails tries to interpolate the SQL query.

Error Location: ee/app/models/concerns/geo/verification_state.rb:131 in needs_reverification_count

Solution

Updated the query to use verification_arel_table[:verified_at] instead of verified_at to properly reference the state table column, resolving the SQL interpolation issue.

References

How to set up and validate locally

  1. Make sure your GDK setup is running Geo
  2. Navigate to http://localhost:3000/admin/sidekiq/morgue and witness the errors;
  3. Checkout this MR's branch
  4. The error should stop appearing in Sidekiq's morgue 🎉

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 Chloe Fons

Merge request reports

Loading