fix(Dataset): add ClassSerializerInterceptor to v4 controller for encoding/decoding metadata keys#2765
Open
abdimo101 wants to merge 7 commits into
Open
fix(Dataset): add ClassSerializerInterceptor to v4 controller for encoding/decoding metadata keys#2765abdimo101 wants to merge 7 commits into
abdimo101 wants to merge 7 commits into
Conversation
…g/decoding metadatakeys
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- You’ve added
@SerializeOptionsto a subset of endpoints only; double-check whether other v4 dataset endpoints that return dataset DTOs (e.g., alternative GETs/POSTs in this controller) also rely on the same metadata encoding/decoding behavior and should use consistent serialization options. - Given that
excludeExtraneousValuesis explicitly set tofalse, confirm this matches how v3 behaves for these DTOs; if v3 relies on stripping unknown fields, you might want to align the v4 serializer options accordingly to avoid subtle response-shape differences.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- You’ve added `@SerializeOptions` to a subset of endpoints only; double-check whether other v4 dataset endpoints that return dataset DTOs (e.g., alternative GETs/POSTs in this controller) also rely on the same metadata encoding/decoding behavior and should use consistent serialization options.
- Given that `excludeExtraneousValues` is explicitly set to `false`, confirm this matches how v3 behaves for these DTOs; if v3 relies on stripping unknown fields, you might want to align the v4 serializer options accordingly to avoid subtle response-shape differences.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
…scicat-backend-next into encode-decode-datasets-v4
There was a problem hiding this comment.
Pull request overview
Adds ClassSerializerInterceptor to the v4 datasets controllers (authenticated and public) so that NestJS class serialization runs on responses, enabling proper encoding/decoding of scientific metadata keys (which the v3 controller already supported). Per-route @SerializeOptions are added to declare the response DTO, and several handlers now return the result of toObject() on the Mongoose document so the serializer sees a plain object.
Changes:
- Apply
@UseInterceptors(ClassSerializerInterceptor)at controller level onDatasetsV4ControllerandDatasetsPublicV4Controller. - Add
@SerializeOptionson create / list / get-by-pid / patch / public endpoints, and convert returned Mongoose documents viatoObject(). - Update unit-test mock to provide a
toObject()method on the mocked update result.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/datasets/datasets.v4.controller.ts | Adds class serializer interceptor, per-route @SerializeOptions, and toObject() conversions on returned documents. |
| src/datasets/datasets-public.v4.controller.ts | Adds class serializer interceptor and @SerializeOptions on the public list/get endpoints. |
| src/datasets/datasets.v4.controller.spec.ts | Extends the update mock to expose toObject() so tests work with the new conversion. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
5 tasks
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.
Description
This PR adds the
ClassSerializerInterceptorto the v4 dataset controller to enable encoding and decoding of scientific metadata keys.Motivation
The interceptor was missing from the v4 controller while it was present in the v3 controller, which caused the encoding and decoding functionality to fail when using the v4 endpoints.
Fixes
Changes:
Tests included
Documentation
official documentation info
Summary by Sourcery
Add response serialization and metadata encoding/decoding support to v4 dataset controller endpoints.
Bug Fixes:
Enhancements: