Skip to content

Handle null owner when indexing projects

Terri Chu requested to merge tchu-fix-owner-not-set-for-project-indexing into master

What does this MR do and why?

context (internal): #428079 (comment 1832554037)

Some project records do not have an owner set. This is causing failures during indexing those records into Elasticsearch in the ProjectInstanceProxy.

undefined method `id' for nil:NilClass data['owner_id'] = target.owner.id ^^^

This MR handles null owner when indexing projects and adds a spec to check it

MR acceptance checklist

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

Screenshots or screen recordings

N/A

How to set up and validate locally

I used specs because I am trying to get this fix in quickly. I'm not sure how to create a project without an owner but ideally you could verify by:

  1. create project without an owner (or manually cause owner to return nil)
  2. call project.as_indexed_json method and verify it does not throw an error
Edited by Terri Chu

Merge request reports

Loading