Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 'Outbound federation will ignore a missing event with bad JSON for room version 6' #1061

Merged
merged 5 commits into from
Jul 7, 2021

Conversation

erikjohnston
Copy link
Member

@erikjohnston erikjohnston commented Jul 1, 2021

We can't assume that homeservers will process inbound federation events synchronously.

In this particular case we replace the check for errors in /send response with a check that if we send a new event that references the expected rejected event we'll see a request for that event come in.

c.f. matrix-org/synapse#10275

…r room version 6'

We can't assume that homeservers will process inbound federation events
synchronously.
@erikjohnston erikjohnston requested a review from a team July 1, 2021 09:55
tests/50federation/33room-get-missing-events.pl Outdated Show resolved Hide resolved
Comment on lines 545 to 573
->then( sub {
my ( $req ) = @_;
my $body = $req->body_from_json;

log_if_fail "Second /get_missing_events body", $body;

log_if_fail "Send response", $body;
assert_json_list( my $earliest = $body->{earliest_events} );
@$earliest == 1 or
die "Expected a single 'earliest_event' ID";

assert_json_keys( $body, 'pdus' );
# 'pdus' is a map from event id to error details.
my $pdus = $body->{pdus};
# It is expected that the earliest event is the m.room.member event,
# but it is possible that the caches have not yet been invalidated
# so also allow any of that event's previous events.
my @expected = @{$latest_event->{prev_events}};
push( @expected, $room->id_for_event( $latest_event ) );
assert_ok( any { $earliest->[0] eq $_ } @expected,
"'earliest_events' did not match" );

# Sending the event fails since fetching the event results in
# invalid JSON, thus we expect an error for the sent PDU.
assert_json_keys( $pdus, $sent_event_id );
assert_json_keys( $pdus->{$sent_event_id}, qw( error ) );
assert_json_list( my $latest = $body->{latest_events} );
@$latest == 1 or
die "Expected a single 'latest_events' ID";
assert_eq( $latest->[0], $marker_event_id,
'latest_events[0]' );

Future->done;
}),
);
$req->respond_json( {
events => [ $sent_event ],
} );

Future->done;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is a cut and paste of the earlier code, let's factor it out to a separate sub ?

@richvdh
Copy link
Member

richvdh commented Jul 1, 2021

do we even still need this test, given it has been ported to complement?

@erikjohnston
Copy link
Member Author

do we even still need this test, given it has been ported to complement?

FTR we decided we do want to keep the test here, at least until we can add worker mode to complement and add it to CI

erikjohnston and others added 2 commits July 2, 2021 15:07
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
@erikjohnston erikjohnston force-pushed the erikj/fix_reject_bad_prev_event branch from 73eb982 to 13029d1 Compare July 5, 2021 11:02
@erikjohnston erikjohnston requested a review from a team July 5, 2021 11:02
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks generally plausible, modulo CI being borked

@erikjohnston erikjohnston merged commit f3b537e into develop Jul 7, 2021
@erikjohnston erikjohnston deleted the erikj/fix_reject_bad_prev_event branch July 7, 2021 14:57
richvdh added a commit to matrix-org/synapse that referenced this pull request Jul 8, 2021
... now that it has been fixed in matrix-org/sytest#1061.
richvdh added a commit to matrix-org/complement that referenced this pull request Jul 9, 2021
…r room version 6' (#152)

This test got blacklisted for the release of Synapse 1.37.1.

We can't assume that homeservers will process inbound federation events synchronously.

In this particular case we replace the check for errors in /send response with a check that if we send a new event that references the expected rejected event we'll see a request for that event come in.

c.f. matrix-org/synapse#10275 and matrix-org/sytest#1061
richvdh added a commit to matrix-org/synapse that referenced this pull request Jul 9, 2021
... now that it has been fixed in matrix-org/sytest#1061.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants