Skip to content

Commit cd349f6

Browse files
mihowclaude
andcommitted
fix: scope heartbeat update to job's project
Filter async services by project when marking them as seen, preventing cross-project contamination when a pipeline is shared across projects. Clarify in the docstring that this still marks all async services on the pipeline within the project, not the individual caller, until application-token auth (PR #1117) is available. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent df4b5f2 commit cd349f6

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

ami/jobs/views.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,23 @@
3232

3333
def _mark_pipeline_pull_services_seen(job: "Job") -> None:
3434
"""
35-
Record a heartbeat for all async (pull-mode) processing services linked to the job's pipeline.
35+
Record a heartbeat for async (pull-mode) processing services linked to the job's pipeline.
3636
3737
Called on every task-fetch and result-submit request so that the worker's polling activity
3838
keeps last_seen/last_seen_live current. The periodic check_processing_services_online task
3939
will mark services offline if this heartbeat stops arriving within PROCESSING_SERVICE_LAST_SEEN_MAX.
4040
41-
Note: caller identity is not verified here — any authenticated token can hit these endpoints.
42-
A future application-token scheme (see PR #1117) will allow tying requests to a specific
43-
processing service so the heartbeat can be scoped more precisely.
41+
IMPORTANT: This marks ALL async services on the pipeline within this project as live, not just
42+
the specific service that made the request. If multiple async services share the same pipeline
43+
within a project, a single worker polling will keep all of them appearing online.
44+
Once application-token auth is available (PR #1117), this should be scoped to the individual
45+
calling service instead.
4446
"""
4547
import datetime
4648

4749
if not job.pipeline_id:
4850
return
49-
job.pipeline.processing_services.async_services().update(
51+
job.pipeline.processing_services.async_services().filter(projects=job.project_id).update(
5052
last_seen=datetime.datetime.now(),
5153
last_seen_live=True,
5254
)

0 commit comments

Comments
 (0)