feat(events): add requester IP and user-agent to sandbox.lifecycle.killed event
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 70/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- go
- Domain
- api, backend, distributed-systems
Research direction
Start at packages/api/internal/handlers/sandbox_kill.go and trace RemoveSandbox through packages/api/internal/orchestrator/delete_instance.go and packages/orchestrator/pkg/server/sandboxes.go. Update the listed RemoveOpts and orchestrator.proto paths, regenerate packages/shared/pkg/grpc/orchestrator/, and verify the killed event includes requester_ip and requester_user_agent for request-triggered kills.
Written by the indexing model from the issue text.
Description
Problem
When a sandbox is killed with kill_reason: "request", the sandbox.lifecycle.killed ClickHouse event carries no information about who initiated the kill — no client IP, no SDK version, no User-Agent. The only caller-identifying data present is sandbox_metadata, which is written at sandbox creation time and reflects the creator, not the killer.
This makes it impossible to answer: "which IP or SDK client sent the DELETE request that killed this sandbox?"
Root Cause
The kill event is emitted inside the orchestrator node's gRPC Delete handler (packages/orchestrator/pkg/server/sandboxes.go). By the time execution reaches there, the original HTTP request context has been lost:
HTTP DELETE /sandboxes/{id} ← gin context has ClientIP, User-Agent, SDK headers
→ RemoveOpts{Reason: "request"} ← no IP/UA fields exist
→ gRPC SandboxDeleteRequest{sandbox_id, kill_reason} ← proto has no IP/UA fields
→ orchestrator Delete handler emits killed event ← no IP/UA available
Proposed Fix
Thread the requester info through the kill path in three layers:
RemoveOpts— addRequesterIP stringandUserAgent stringfieldsSandboxDeleteRequestproto — addoptional string requester_ip = 3andoptional string requester_user_agent = 4- Orchestrator
Deletehandler — write both fields intoeventDatabefore emitting the killed event
Call site in handlers/sandbox_kill.go:
err = a.orchestrator.RemoveSandbox(ctx, teamID, sandboxID, sandbox.RemoveOpts{
Action: sandbox.StateActionKill,
Reason: sandbox.KillReasonRequest,
RequesterIP: c.ClientIP(),
UserAgent: c.Request.UserAgent(),
})
Resulting ClickHouse event_data:
{
"kill_reason": "request",
"requester_ip": "1.2.3.4",
"requester_user_agent": "e2b-js-sdk/1.9.0",
"sandbox_metadata": { ... }
}
Files Affected
packages/api/internal/sandbox/sandboxtypes/states.gopackages/api/internal/handlers/sandbox_kill.gopackages/api/internal/orchestrator/delete_instance.gopackages/orchestrator/orchestrator.proto+ regeneratepackages/shared/pkg/grpc/orchestrator/packages/orchestrator/pkg/server/sandboxes.go
- Dominant language
- Go
- Stars
- 1.6k
- Forks
- 438
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from e2b-dev/runtime
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
sandbox cache: StartRemoving state transition not broadcast, all allocations see stale Running state Open
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Similar issues
-
kind/bug needs-triage
Difficulty 1/5 Under an hour Newbie friendliness 72/100
matrixorigin/matrixone#29223 ·
-
needs-acceptance wg/data-plane-networking
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
vllm-project/semantic-router#4024 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
alexgorbatchev/dotfiles#107 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100