Skip to content

Wrap API response data in DeepReadonly#362

Open
thearyanahmed wants to merge 1 commit into
oxidecomputer:mainfrom
thearyanahmed:readonly-response-data
Open

Wrap API response data in DeepReadonly#362
thearyanahmed wants to merge 1 commit into
oxidecomputer:mainfrom
thearyanahmed:readonly-response-data

Conversation

@thearyanahmed

@thearyanahmed thearyanahmed commented Jul 5, 2026

Copy link
Copy Markdown

Addresses #329.

This PR wraps API response payloads in DeepReadonly<T> so they can't be mutated, nested objects and arrays included. Covers both success (ApiSuccess.data) and API error (ErrorResult's ErrorBody) responses; the client-side client_error variant gets readonly bindings for consistency.

Applied at the response boundary in http-client.ts, so request bodies stay mutable: a shared schema is mutable when you build a request and frozen when it comes back. Date is passed through untouched.

I am a bit uncertain if that is what issue 329 wants or is it expected to have the DeepReadonly around the whole type. I went with this approach as this keeps the server's response readonly.

@thearyanahmed thearyanahmed force-pushed the readonly-response-data branch from 612dab3 to 23b44f1 Compare July 5, 2026 15:27
@thearyanahmed thearyanahmed marked this pull request as ready for review July 5, 2026 15:30
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.

1 participant