Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PB-557] bug: file size from the drive-server comes as string #417

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

edisonjpadilla
Copy link

@edisonjpadilla edisonjpadilla commented Sep 21, 2023

Added the virtual field numericSize in order to return the file size as a number instead of string. Whichever client needs the size as a number could simply use this property.

Copy link
Contributor

@JoanVicens JoanVicens left a comment

Choose a reason for hiding this comment

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

Tested and works, but why do we parser to a float? The size is in bytes so it shuld be always an integer

imatge

@edisonjpadilla
Copy link
Author

edisonjpadilla commented Sep 21, 2023

@JoanVicens I thought the size was measured in MB, I'll make the change.

@edisonjpadilla edisonjpadilla force-pushed the bug/file-size-from-the-drive-server-comes-as-string branch from ebb3da2 to 3c33821 Compare September 21, 2023 12:26
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@JoanVicens
Copy link
Contributor

@PixoDev Can this break anything on mac?

@PixoDev
Copy link
Contributor

PixoDev commented Sep 21, 2023

This will break a lot of API responses in the MacOS app because we are expecting an string there @JoanVicens @edisonjpadilla.

Let me think a solution for this so we don't break production already please, don't merge this yet. Will this apply to all the responses that includes the size field?

@JoanVicens JoanVicens self-requested a review September 21, 2023 13:58
Copy link
Contributor

@JoanVicens JoanVicens left a comment

Choose a reason for hiding this comment

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

Added a new review to block the merge button. We need to ensure this will not break any client

@JoanVicens
Copy link
Contributor

We could add a new field so the clients can migrate to it and once every client no longer uses it change the size to number (and migrate again?) @sg-gs

@jzunigax2
Copy link
Contributor

We could add a new field so the clients can migrate to it and once every client no longer uses it change the size to number (and migrate again?) @sg-gs

@JoanVicens I was taking a look into this old issue, is this approach still needed?

@JoanVicens
Copy link
Contributor

We could add a new field so the clients can migrate to it and once every client no longer uses it change the size to number (and migrate again?) @sg-gs

@JoanVicens I was taking a look into this old issue, is this approach still needed?

Yes, I believe that the parsing of the JSON on the Mac application relies on the type of the fields being what they expect, so changing the size to a number would be a breaking change.

@jzunigax2 jzunigax2 requested a review from apsantiso as a code owner June 4, 2024 17:08
@jzunigax2 jzunigax2 self-assigned this Jun 4, 2024
@jzunigax2 jzunigax2 requested a review from JoanVicens June 4, 2024 17:26
@apsantiso
Copy link
Collaborator

apsantiso commented Jun 12, 2024

This solution is the way to go if we aim for non breaking changes, but it introduces technical debt. Specifically, you would need to replicate this approach in the drive-server-wip repository (you could add it to the domain layer instead of using a virtual value). Moreover, if we decide to change the size to numeric, the client currently using this virtual value would need to switch back to using size.

This issue originates from Sequelize, where the size ( in the DB ) column is of type "bigint". Sequelize cannot ensure that very large numbers are safely parsed to Number, so it parses this column as a String for such cases. However, the MAX SAFE INTEGER in JavaScript is close to 8000TB (9007199254740991 in bytes), so we can safely parse this to Number without any problems if needed.

@sg-gs @jzunigax2 Feel free to merge this, but I believe such issues should be addressed at the root level. Instead of adding more fields, we could have the macOS client handle either strings or numbers if possible.

I mention this because I've also had issues with this field being of string type on drive-server-wip while building the workspaces feature (when comparing size < free space, for instance)

@jzunigax2 jzunigax2 force-pushed the bug/file-size-from-the-drive-server-comes-as-string branch from 021afbe to 50f0afe Compare June 20, 2024 20:51
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants