fix(aci): Forbid unsafe legacy interactions with shared Workflows/Detectors#116532
Conversation
ceorourke
left a comment
There was a problem hiding this comment.
Fix makes sense, but what's the valid reason that a rule or alert rule would be mapped to multiple workflows?
We expose an endpoint to dedup workflows, which specifically creates that multiple mapping. |
…low deletion (#116537) It's broken for project deletion to result in org-scoped workflow deletion, and for teams with legacy alerting models, this is a real risk. It's not too troubling if the project was the only user of the workflow, and arguably expected, but removing org-scoped data when no longer used anywhere is a choice we haven't yet made, so best to default to the safest path. The legacy Rule endpoint still will delete the Workflow associated, which is troublesome in sharing cases, but will be addressed elsewhere. This is spun off of #116532.
| workflow__organization=project.organization, | ||
| workflow__status=ObjectStatus.ACTIVE, | ||
| ) |
There was a problem hiding this comment.
Bug: PUT requests bypass the shared workflow modification check because they don't set the use_workflow_engine flag, falling back to a legacy path without the protection.
Severity: HIGH
Suggested Fix
Update the condition for use_workflow_engine to include PUT requests unconditionally, similar to how GET and DELETE are handled. This will ensure that PUT requests enter the new code path where the shared workflow check is performed. Additionally, add a test case to verify that PUT requests on shared workflows are correctly blocked.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: src/sentry/api/bases/rule.py#L78-L80
Potential issue: The logic to determine whether to use the new workflow engine path,
controlled by the `use_workflow_engine` variable, is only enabled for `GET` and `DELETE`
requests by default. For `PUT` requests, it depends on a `method_flag` which is not set,
causing these requests to fall back to the legacy code path. The check that prevents
modification of shared workflows is only present in the new `if use_workflow_engine:`
block. This allows users to modify rules backed by a shared workflow via a `PUT`
request, which contradicts the intended behavior of the change.
Did we get this right? 👍 / 👎 to inform future reviews.
|
PR reverted: aa8dbc0 |
|
This was reverted due to it being unintentionally merged; it was marked auto-merge hours ago accidentally, then updated to no longer be failing without awareness of that, causing it to merge. |
For reasons valid and otherwise, it's possible to have multiple legacy models (Rule, AlertRule) mapped to the same Workflow or Detector.
For read purposes, this can be convenient for preserving the old interface, but mutations in this case are confusing at best.
Moreover, our deletion code had assumed no sharing, which meant that deleting a Rule can result in a workflow used by many other projects being deleted, which is almost certainly not the intended behavior.
To address this, here we:
The second part in particular may prove annoying, but we can fix it by un-merging (in some cases) or they can use new APIs.