parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

transformInteriorValue doesn't handle conversion properly

Open kassiansun opened this issue 10 months ago • 4 comments

New Issue Checklist

Issue Description

Since transformInteriorValue https://github.com/parse-community/parse-server/commit/4d4361451cdefa2592b92e8fd54c459b03190205, the code never trigger the logics after value !== CannotTransform. This bug was noticed and fixed in #8209 in a wrong way, and later #8446 introduced a (partially) corrected but duplicated fix.

Steps to reproduce

Actual Outcome

Expected Outcome

Environment

Server

  • Parse Server version: 7.4.0
  • Operating system: Ubuntu
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): AWS

Database

  • System (MongoDB or Postgres): MongoDB
  • Database version: 5.0.18
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): AWS

Client

  • SDK (iOS, Android, JavaScript, PHP, Unity, etc): JavaScript
  • SDK version: 5.3.0

Logs

kassiansun avatar Jan 22 '25 06:01 kassiansun

Thanks for opening this issue!

  • 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

Is this a bug, or just a code refactoring without any effects on performance or behavior?

mtrezza avatar Jan 22 '25 11:01 mtrezza

Is this a bug, or just a code refactoring without any effects on performance or behavior?

I didn't test it, but I think the RegExp and Bytes are all broken since #8446, because if (value && typeof value === 'object') { will be true for both, so the value saved in database will be a JSON-serialized version of mongodb.Bytes and mongodb.RegExp (or not broken if mapValues(restValue, transformInteriorValue) doesn't change the value of the object, but this is a coincidence instead of an explicit specified behavior).

Also this logic is handled properly after #9566, which is a definitely a behavior change (although it's from the original refactoring, but it never triggered since that):

// Handle update operators
  if (typeof restValue === 'object' && '__op' in restValue) {
    return transformUpdateOperator(restValue, true);
  }

kassiansun avatar Jan 22 '25 12:01 kassiansun

Ok, we keep this classified as a bug. Could you please make sure the PR contains a test that demonstrates the issue?

mtrezza avatar Jan 23 '25 22:01 mtrezza