Skip to content

fix: parse serverless networkVolumeIds returned as id strings#292

Open
TimPietruskyRunPod wants to merge 2 commits into
mainfrom
fix/serverless-networkvolumeids-parse
Open

fix: parse serverless networkVolumeIds returned as id strings#292
TimPietruskyRunPod wants to merge 2 commits into
mainfrom
fix/serverless-networkvolumeids-parse

Conversation

@TimPietruskyRunPod

Copy link
Copy Markdown
Member

problem

runpodctl serverless get and serverless list both fail for every endpoint that has a network volume attached:

failed to parse response: json: cannot unmarshal string into Go struct field Endpoint.networkVolumeIds of type api.EndpointNetworkVolume

the rest read endpoint returns networkVolumeIds as an array of bare id strings:

"networkVolumeIds": ["x3s11yfqg9"]

but the Endpoint struct only accepted the graphql saveEndpoint write shape ([{"networkVolumeId":"..."}]). read and write shapes differ, so all serverless reads broke.

fix

add a custom UnmarshalJSON on EndpointNetworkVolume that accepts either a bare id string (rest read) or an object (graphql write). no change to the write path.

testing

  • unit test covering both shapes (TestEndpointNetworkVolumeIDsUnmarshal)
  • e2e against the live api: serverless get and serverless list now succeed on endpoints with attached network volumes (previously errored). read-only, no resources created.

the rest read endpoint returns networkVolumeIds as bare id strings
([vol-1]), but the Endpoint struct only accepted the graphql write
shape ([{networkVolumeId}]), so every serverless get/list failed with
a json unmarshal error. add a custom UnmarshalJSON on
EndpointNetworkVolume that accepts either shape.
the existing get/list tests re-encoded an Endpoint struct as the mock
response, so the fixture json always matched the struct (object-shape
networkVolumeIds) and could never catch a read/write shape divergence.
serve raw rest wire json instead (networkVolumeIds as bare id strings)
and assert it parses, so a regression to a single-shape struct fails
at the function level, not just in the unmarshal unit test.
@justinwlin justinwlin self-requested a review June 26, 2026 15:04
@gabe-engineers

Copy link
Copy Markdown

Closes #288

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants