Abuse Report exception (nil class)

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

Opening some abuse reports will show a 500 and the logs show:

undefined method `notes' for nil:NilClass

     reported_project.notes.id_in(note_id_from_url).pick(:note_html)
                           ^^^^^^

https://gitlab.com/gitlab-org/gitlab/-/blob/91c6434080c94452fed2dc601fecf4ff478b6b0e/app/models/abuse_report.rb#L150

Sorry this one cuts off, there's an issue with our Kubernetes log collector which truncates logs at 8k chars.

"exception.backtrace":[
        "app/models/abuse_report.rb:150:in `reported_content'",
        "ee/app/models/ee/abuse_report.rb:27:in `reported_content'",
        "grape-entity (1.0.1) lib/grape_entity/delegator/plain_object.rb:8:in `delegate'",
        "grape-entity (1.0.1) lib/grape_entity/entity.rb:546:in `delegate_attribute'",
        "grape-entity (1.0.1) lib/grape_entity/exposure/delegator_exposure.rb:8:in `value'",
        "grape-entity (1.0.1) lib/grape_entity/exposure/base.rb:91:in `valid_value'",
        "grape-entity (1.0.1) lib/grape_entity/exposure/base.rb:73:in `serializable_value'",
        "grape-entity (1.0.1) lib/grape_entity/exposure/nesting_exposure.rb:41:in `block in serializable_value'",
        "grape-entity (1.0.1) lib/grape_entity/exposure/nesting_exposure.rb:122:in `block (2 levels) in map_entity_exposures'",
        "grape-entity (1.0.1) lib/grape_entity/options.rb:90:in `with_attr_path'",
        "grape-entity (1.0.1) lib/grape_entity/exposure/base.rb:125:in `with_attr_path'",
        "grape-entity (1.0.1) lib/grape_entity/exposure/nesting_exposure.rb:121:in `block in map_entity_exposures'",
        "grape-entity (1.0.1) lib/grape_entity/exposure/nesting_exposure.rb:120:in `each'",
        "grape-entity (1.0.1) lib/grape_entity/exposure/nesting_exposure.rb:120:in `each_with_object'",
        "grape-entity (1.0.1) lib/grape_entity/exposure/nesting_exposure.rb:120:in `map_entity_exposures'",
        "grape-entity (1.0.1) lib/grape_entity/exposure/nesting_exposure.rb:40:in `serializable_value'",
        "grape-entity (1.0.1) lib/grape_entity/entity.rb:513:in `serializable_hash'",
        "grape-entity (1.0.1) lib/grape_entity/exposure/base.rb:76:in `serializable_value'",
        "grape-entity (1.0.1) lib/grape_entity/exposure/nesting_exposure.rb:41:in `block in serializable_value'",
        "grape-entity (1.0.1) lib/grape_entity/exposure/nesting_exposure.rb:122:in `block (2 levels) in map_entity_exposures'",
        "grape-entity (1.0.1) lib/grape

Steps to reproduce

No idea. The abuse report was for a spam comment. We tried reporting a comment, and deleting the comment and it seems fine.

Example Project

N/A - private ultimate instance.

What is the current bug behavior?

Screenshot_2024-11-19_at_16.54.57

What is the expected correct behavior?

It should show the abuse report.

Relevant logs and/or screenshots

N/a

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes

Edited by 🤖 GitLab Bot 🤖