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 issue that causes illegal diff query #5291

Merged
merged 2 commits into from
Dec 22, 2024

Conversation

ajtmccarty
Copy link
Contributor

@ajtmccarty ajtmccarty commented Dec 20, 2024

IFC-1013

when aggregating multiple diffs as part of a diff update, if any diffs in the aggregation list overlapped it would cause an illegal diff query to be created in which the to_time was before the from_time

this fix is to go through the list of diffs to aggregate and remove any that overlap, giving preference to the diff that covers the greater time range

also fixes a small bug in the diff query that could cause a diff for an arbitrary time frame (meaning a to_time other than "right now") to not include changes. this is not something a user would encounter unless they are using GraphQL to generate their own diffs with arbitrary time ranges outside of the branch/proposed change process. and I highly doubt anyone is doing that

@github-actions github-actions bot added the group/backend Issue related to the backend (API Server, Git Agent) label Dec 20, 2024
Copy link

codspeed-hq bot commented Dec 20, 2024

CodSpeed Performance Report

Merging #5291 will not alter performance

Comparing ajtm-12202024-illegal-diff-query (1c01b38) with stable (d6c8ec5)

Summary

✅ 10 untouched benchmarks

@ajtmccarty ajtmccarty marked this pull request as ready for review December 20, 2024 23:19
@ajtmccarty ajtmccarty requested a review from a team December 20, 2024 23:19
# keep the diff that covers the larger time frame
if candidate_interval > previous_interval:
ordered_diffs_no_overlaps[-1] = candidate_diff_pair
return ordered_diffs_no_overlaps
Copy link
Contributor Author

Choose a reason for hiding this comment

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

strip out overlapping diffs. when two diffs overlap, keep the one that covers the greater time range

remaining_diffs = sorted(partial_enriched_diffs, key=lambda d: d.diff_branch_diff.from_time)
ordered_diffs = self._get_ordered_diff_pairs(diff_pairs=partial_enriched_diffs, allow_overlap=False)
ordered_diff_reprs = [repr(d) for d in ordered_diffs]
log.debug(f"Ordered diffs for aggregation: {ordered_diff_reprs}")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

a little logging to help us troubleshoot if this comes up again

if sorted_time_ranges[-1].to_time < to_time:
missing_time_ranges.append(TimeRange(from_time=sorted_time_ranges[-1].to_time, to_time=to_time))
return missing_time_ranges

Copy link
Contributor Author

Choose a reason for hiding this comment

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

dead code

AND (
(from_time <= diff_rel.from < $to_time)
OR (from_time <= diff_rel.to < $to_time)
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix in the query to calculate a diff

assert property_diff.previous_value is False
assert property_diff.new_value is None
assert property_diff.action is DiffAction.REMOVED
assert before_main_change < property_diff.changed_at < after_main_change
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix to this unit test after the fix to the diff query

@ajtmccarty ajtmccarty merged commit 4d32ce6 into stable Dec 22, 2024
28 checks passed
@ajtmccarty ajtmccarty deleted the ajtm-12202024-illegal-diff-query branch December 22, 2024 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
group/backend Issue related to the backend (API Server, Git Agent)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants