fix(api): add nil guard in volume mount response conversion
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
Research direction
Start in packages/api/internal/handlers/sandboxes_list.go at convertFromDBMountsToAPIMounts, then review the related cases in packages/api/internal/handlers/volume_util_test.go. Run the handler tests and add coverage for a nil mount element. Done means sparse input no longer panics and nil entries are omitted from the API response.
Written by the indexing model from the issue text.
Description
Problem
In packages/api/internal/handlers/sandboxes_list.go, convertFromDBMountsToAPIMounts converts database volume mount slice items into API response structs (api.SandboxVolumeMount). If the input slice contains a nil element (e.g. unmarshaled from JSONB payloads containing sparse/null entries), accessing item.Name or item.Path triggers a nil pointer dereference panic, failing the active HTTP request goroutine for sandbox GET/LIST endpoints.
Root Cause
convertFromDBMountsToAPIMounts iterated directly over mounts without checking if item == nil.
| Setting / Factor | Current Value / State | Intended / Expected |
|---|---|---|
| File / Component | packages/api/internal/handlers/sandboxes_list.go:L346-L359 |
Defensive nil element guard |
| Behavior | item.Name dereference panics on nil item |
Skip nil items safely |
Reproduction Steps
- Invoke
convertFromDBMountsToAPIMounts([]*dbtypes.SandboxVolumeMountConfig{nil}). - Observed result: Nil pointer dereference panic.
- Expected result: Skips
nilitem, returns empty slice pointer.
mounts := []*dbtypes.SandboxVolumeMountConfig{nil}
res := convertFromDBMountsToAPIMounts(mounts) // panics on item.Name
Technical Context
- Files affected:
packages/api/internal/handlers/sandboxes_list.go,packages/api/internal/handlers/volume_util_test.go - Subsystem: Control Plane API
- Impact: Low/Medium (Defensive nil safety)
Proposed Changes
| # | Change | File(s) Affected | Complexity |
|---|---|---|---|
| 1 | Add if item == nil { continue } guard in convertFromDBMountsToAPIMounts |
sandboxes_list.go |
Low |
| 2 | Add unit tests in volume_util_test.go |
volume_util_test.go |
Low |
- 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
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
enhancement needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
kind/cleanup
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
kubernetes-sigs/kueue#15947 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
sympozium-ai/sympozium#627 ·
-
priority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/librarian#7636 ·