Page MenuHomePhabricator

[Flow] improve report related types
ClosedPublic

Authored by kamil on Nov 15 2023, 4:07 AM.
Tags
None
Referenced Files
F3516251: D9893.id33257.diff
Sun, Dec 22, 1:04 PM
F3516243: D9893.id33253.diff
Sun, Dec 22, 1:02 PM
F3516165: D9893.id33254.diff
Sun, Dec 22, 12:35 PM
F3515130: D9893.diff
Sun, Dec 22, 7:36 AM
Unknown Object (File)
Sat, Dec 21, 10:18 AM
Unknown Object (File)
Sun, Dec 15, 11:58 PM
Unknown Object (File)
Sun, Dec 15, 11:58 PM
Unknown Object (File)
Sun, Dec 15, 11:58 PM
Subscribers

Details

Summary

D7916 introduced id field on the client side to identify reports and avoid comparing the entire blob each time - this is different from keyserver id assigned by the backend database.

It was properly added for ClientThreadInconsistencyReportCreationRequest and ClientEntryInconsistencyReportCreationRequest which are only ClientReportCreationRequest.

By mistake, it was also added for ErrorReportCreationRequest, MediaMissionReportCreationRequest and UserInconsistencyReportCreationRequest types which are used as both ClientReportCreationRequest and ReportCreationRequest.

That caused diverging types, invalid validators (keyserver validators were implemented without the id field) and a lot of confusion pointed out by @ashoat here:

This shouldn't cause any issues for older clients, the id field is extracted in the current code version, and also was in the past (D7910).

The main issue is that validators were not reflected in types, this diff should fix this.

Test Plan
  1. FLow.
  2. Make sure validators are properly defined (without id field).
  3. report-store-reducer.test.js and report-store-ops.test.js.
  4. Try sending some reports and make sure it succeeded..

Diff Detail

Repository
rCOMM Comm
Branch
fix-report-types
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

kamil held this revision as a draft.
kamil added inline comments.
lib/utils/reports-service.js
20–32

adding this explicitly, to make it more clear

kamil published this revision for review.Nov 15 2023, 4:22 AM

Seems reasonable to me. I haven't audited all places on the client where reports are constructed – hoping you went through all of those cases carefully

native/input/input-state-container.react.js
157

Looks like your IDE accidentally added this

This revision is now accepted and ready to land.Nov 15 2023, 4:49 AM

Seems reasonable to me. I haven't audited all places on the client where reports are constructed – hoping you went through all of those cases carefully

Yes, I made sure that ReportCreationRequest types are used only on keyserver, and on the client we use those with Client* prefix

This revision was automatically updated to reflect the committed changes.