Repository navigation
Skip the class-transformer response pass on the v6 client controller - #3395
Merged
Merged
Conversation
Every /v6 route returns plain data (literals, raw rows, string arrays, or objects already built in the response shape), so routing-controllers' instanceToPlain only deep-copied each response before JSON.stringify. It is now off for the whole client controller via @jsoncontroller options; a route can opt back in with { transformResponse: true }. Request bodies are still transformed into their validator classes and validated. Adds the first ExperimentClientController tests: over HTTP, /assign, /featureflag, /useraliases and /reward return a class instance whose @exclude'd field survives only if the transform is skipped, and an invalid /assign body is still rejected before reaching the service. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
Static review supports the narrowly scoped change with no blocking findings; tests were not executed.
No open issues 🎉
What changed in this PR
Removes the response-side class-transformer pass from the v6 client controller to reduce serialization overhead, particularly for large assignment responses. Request transformation and validation remain enabled.
Changes:
- Disables response transformation controller-wide, with per-route opt-in available.
- Adds HTTP tests verifying transformation is skipped for four endpoints and invalid assignment requests are still rejected.
| File | Description |
|---|---|
| packages/backend/test/unit/controllers/ExperimentClientController.test.ts | Adds response-transformation and request-validation regression tests. |
| packages/backend/src/api/controllers/ExperimentClientController.v6.ts | Disables response transformation and documents the scope and opt-in option. |
Review effort: Balanced
bcb37
approved these changes
Oct 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
class-transformeris adding a "transform" on every request and response (classTransformer: truein app.ts). this is to apply decorators, which we use all over the place for requests, but responses in client controller don't use any decorators that actually change any outgoing response, so it's just making a copy.this is probably pretty negligible for most responses, but it isn't for assign responses, especially for express-mode within-subjects responses. it causes a small but noticeable wait, which is made much worse during bursts where everything waiting on the thread inherits every wait ahead of it.
This turns off the response transform for the whole v6 client controller. Request bodies are unaffected: they're still transformed into validator classes and validated. The JSON sent is unchanged; the new controller tests check this over HTTP for /assign, /featureflag, /useraliases and /reward. Any route that later needs the response transform can opt back in with { transformResponse: true }.