fix(provider_availability): clear Buffer holds when a buffer is removed from a rule - #434
Open
canvas-investigator[bot] wants to merge 1 commit into
Open
fix(provider_availability): clear Buffer holds when a buffer is removed from a rule#434canvas-investigator[bot] wants to merge 1 commit into
canvas-investigator[bot] wants to merge 1 commit into
Conversation
Contributor
|
cerberus review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🧵 Cecilia Orta cc @ceciliaorta
Generated by the Investigator
Problem
When a provider's appointment buffer is removed (or zeroed) on an availability rule, the "Buffer" calendar holds the plugin previously placed on that provider's Administrative calendar are not deleted. The admin UI shows the buffer as gone, but the stale holds remain and keep blocking slots that should now be bookable.
Reported from a production instance (Rivia) that is standardizing on no buffers — removing them provider-by-provider and finding orphaned holds left behind each time.
Evidence (production)
Future, non-cancelled
title = "Buffer"events on Administrative calendars:Why it happens
Two issues, both present in this reference:
appointment_buffer.pyonly reconciles fromAPPOINTMENT_CREATED / RESCHEDULED / CANCELED. Editing/removing a buffer on a rule (or deleting the rule) emits no appointment event, so the holds are never revisited._reconcile_buffers,if pre_buffer == 0 and post_buffer == 0: return []returned before the "delete existing Buffer events" step — so even when an appointment event later fired for a zeroed-buffer provider, the stranded holds were never removed.Fix
provider_availability/protocols/appointment_buffer.pyreconcile_buffers_for_provider(provider_id, action).provider_availability/api/availability_api.pyreconcile_buffers_for_provider(...)from the rule create/update (POST/PUT /rules) and delete (DELETE /rules/<provider>/<rule>,DELETE /rules/<provider>) handlers, alongside the existingsync_provider_availability(...). Removing a buffer now cleans its holds immediately, at save time.Tests
tests/protocols/test_appointment_buffer.py: deletion when a buffer is zeroed, deletion when the provider has no rule, delete-then-recreate when a buffer is present, and the bounded recreation query.tests/api/conftest.py(autouse) stubbing the buffer pass for the rule-CRUD API tests, which assert availability-sync effects only.uv run pytest→ 757 passed.This reference is v0.17.2 (cache-backed). The reporting instance runs a diverged v0.20.2 (custom_data + a day-bounded buffer reconcile) that is not in this repo — a production-hardened build that was never ported back to the reference (same situation as
gcal_sync#429).pre == 0 and post == 0early-return in its day-bounded_reconcile_buffers, and (2) call a provider-scoped reconcile from its rule create/update/delete API paths. Then port the v0.20.2 line back to this reference (per the gcal_sync v0.6.1 — idempotent push, multi-attendee fix, fleet ops #429 pattern).Scope notes