fix: claim the message id before creating the message - #47
Merged
Merged
Conversation
activity-api answered 201 seventeen seconds after a create call whose client had given up at ten, so the id never reached the database. At close the ref carried no message_id, no deletion was scheduled, and the card stayed in Teams with nothing left pointing at it. The id is now generated and stored before the call, so a lost answer costs nothing. A create refused outright with 400 or 409 gives the id back, and so does any patch activity-api answers with `invalid message_id`: without that, a ref would be stuck patching a ghost and the merge request would never get a card at all. Claiming first also settles the concurrent-create race with no compensating delete, since the loser never posts. ACTIVITY_API_TIMEOUT_SECONDS and GITLAB_API_TIMEOUT_SECONDS replace the hard-coded timeouts, same defaults.
starlette 1.x makes its TestClient import httpx2 and raises on the httpx fallback, so collection of the integration tests fails on a fresh install.
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.
Fixes the orphaned Teams card: a merge request was closed, its notification updated, and the card stayed up forever with nothing pointing at it.
activity-api answered
201seventeen seconds after the create call. The client had given up at ten, so the returned id was never stored. The message existed in Teams, the ref carriedmessage_id = NULL, and at close the deletion scheduler skipped it and dropped the ref.Change
merge_request_message_refbefore the create call, then sent in the payload. A lost answer no longer loses the handle.400/409, both answered before anything reaches Teams) gives the id back. So does any patch activity-api answers withinvalid message_id. Without that, a ref would stay locked onto an id nothing can resolve and the merge request would never get a card at all.DELETEis gone, about 40 lines removed.message_idis now logged as a possible orphan instead of being dropped silently.periodic_cleanuptreats activity-api'sinvalid message_idas terminal, so an id claimed but never delivered cannot loop forever inmsg_to_delete.ACTIVITY_API_TIMEOUT_SECONDSandGITLAB_API_TIMEOUT_SECONDSreplace five hard-coded values, same defaults.Deploy order
Requires
activity-api >= 0.12.0, which adds the caller-chosenmessage_idfield. Deploy it first. Against an older activity-api the field is silently ignored (pydanticextra='ignore') and behaviour falls back to what it is today, so nothing breaks, but the bug is not fixed until both are up.256 tests, 84% coverage. Every new guard was checked red against the code without the fix.