Skip to content

fix(Dataset): add ClassSerializerInterceptor to v4 controller for encoding/decoding metadata keys#2765

Open
abdimo101 wants to merge 7 commits into
masterfrom
encode-decode-datasets-v4
Open

fix(Dataset): add ClassSerializerInterceptor to v4 controller for encoding/decoding metadata keys#2765
abdimo101 wants to merge 7 commits into
masterfrom
encode-decode-datasets-v4

Conversation

@abdimo101
Copy link
Copy Markdown
Member

@abdimo101 abdimo101 commented Jun 1, 2026

Description

This PR adds the ClassSerializerInterceptor to 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

  • Bug fixed (#X)

Changes:

  • changes made

Tests included

  • Included for each change/fix?
  • Passing?

Documentation

  • swagger documentation updated (required for API changes)
  • official documentation updated

official documentation info

Summary by Sourcery

Add response serialization and metadata encoding/decoding support to v4 dataset controller endpoints.

Bug Fixes:

  • Ensure v4 dataset endpoints correctly encode and decode scientific metadata keys via ClassSerializerInterceptor.

Enhancements:

  • Apply ClassSerializerInterceptor at the v4 datasets controller level and configure serialization options for create, list, get-by-pid, and patch dataset endpoints.

@abdimo101 abdimo101 requested a review from a team as a code owner June 1, 2026 13:42
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • 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.
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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@abdimo101 abdimo101 requested a review from Junjiequan June 1, 2026 13:44
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 on DatasetsV4Controller and DatasetsPublicV4Controller.
  • Add @SerializeOptions on create / list / get-by-pid / patch / public endpoints, and convert returned Mongoose documents via toObject().
  • 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.

Comment thread src/datasets/datasets.v4.controller.ts
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.

2 participants