Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • pleroma pleroma
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 578
    • Issues 578
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 94
    • Merge requests 94
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Pleroma
  • pleromapleroma
  • Issues
  • #2560

Closed
Open
Created Mar 05, 2021 by Alex Gleason@alexgleasonContributor

Report contains a nil object, AdminAPI gives a 500 error

GET /api/pleroma/admin/reports is returning a 500 error with this in the logs:

Mar 05 21:22:33 spinster mix[1435463]: Server: spinster.xyz:80 (http)
Mar 05 21:22:33 spinster mix[1435463]: Request: GET /api/pleroma/admin/reports
Mar 05 21:22:33 spinster mix[1435463]: ** (exit) an exception was raised:
Mar 05 21:22:33 spinster mix[1435463]:     ** (FunctionClauseError) no function clause matching in anonymous fn/1 in Pleroma.Web.AdminAPI.Report.extract_report_info/1
Mar 05 21:22:33 spinster mix[1435463]:         (pleroma 2.2.50-595-g562ecf28-spinster) lib/pleroma/web/admin_api/report.ex:16: anonymous fn(nil) in Pleroma.Web.AdminAPI.Report.extract_report_info/1
Mar 05 21:22:33 spinster mix[1435463]:         (elixir 1.10.4) lib/enum.ex:1396: Enum."-map/2-lists^map/1-0-"/2
Mar 05 21:22:33 spinster mix[1435463]:         (pleroma 2.2.50-595-g562ecf28-spinster) lib/pleroma/web/admin_api/report.ex:16: Pleroma.Web.AdminAPI.Report.extract_report_info/1
Mar 05 21:22:33 spinster mix[1435463]:         (elixir 1.10.4) lib/enum.ex:1396: Enum."-map/2-lists^map/1-0-"/2
Mar 05 21:22:33 spinster mix[1435463]:         (elixir 1.10.4) lib/enum.ex:1396: Enum."-map/2-lists^map/1-0-"/2
Mar 05 21:22:33 spinster mix[1435463]:         (pleroma 2.2.50-595-g562ecf28-spinster) lib/pleroma/web/admin_api/views/report_view.ex:21: Pleroma.Web.AdminAPI.ReportView.render/2
Mar 05 21:22:33 spinster mix[1435463]:         (phoenix 1.5.6) lib/phoenix/view.ex:472: Phoenix.View.render_to_iodata/3
Mar 05 21:22:33 spinster mix[1435463]:         (phoenix 1.5.6) lib/phoenix/controller.ex:776: Phoenix.Controller.render_and_send/4

The offending code is here:

statuses =
  Enum.map(status_ap_ids, fn
    act when is_map(act) -> Activity.get_by_ap_id_with_object(act["id"])
    act when is_binary(act) -> Activity.get_by_ap_id_with_object(act)
  end)

It's trying parse the status IDs from the Flag activity, but one of them is nil, so there's no match.

I found the offending report in the database and it looks like this:

{
  "cc": [],
  "id": "https://spinster.xyz/activities/******",
  "to": [],
  "type": "Flag",
  "actor": "https://spinster.xyz/users/******",
  "state": "closed",
  "object": [
    "https://poa.st/users/******",
    null
  ],
  "content": "",
  "context": "https://spinster.xyz/contexts/******",
  "published": "2021-03-05T00:00:00",
  "context_id": 123456
}

As you can see, the "object" field contains a null value... how? I don't really know. I guess we should prevent this from happening in the first place if we can, but we should also handle the circumstance where a null value is in there.

Edited Aug 11, 2021 by Alex Gleason
Assignee
Assign to
Time tracking