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

fix: File upload fails when uploading base64 data #1578

Merged
merged 18 commits into from
Nov 3, 2022
Merged

fix: File upload fails when uploading base64 data #1578

merged 18 commits into from
Nov 3, 2022

Conversation

musthafa1996
Copy link
Contributor

@musthafa1996 musthafa1996 commented Oct 21, 2022

New Pull Request Checklist

Issue Description

Parse server throws the following error while uploading files:
The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined

Related issue: #1579, parse-community/parse-server#8253
Closes #1579, parse-community/parse-server#8253

Approach

Add in the missing assignment of _data property with the uploaded file data in ParseFile.js

TODOs before merging

  • Add tests
  • Remove overriding of Parse server in package.json
  • Rollback the content of package-lock.json
  • Add entry to changelog
  • Add changes to documentation (guides, repository pages, in-code descriptions)x

@parse-github-assistant
Copy link

parse-github-assistant bot commented Oct 21, 2022

Thanks for opening this pull request!

  • 🎉 We are excited about your hands-on contribution!

@musthafa1996 musthafa1996 mentioned this pull request Oct 21, 2022
4 tasks
@musthafa1996 musthafa1996 changed the title Override parse SDK to v3.5.0-alpha.6 in parse-server fix: File file upload issue Oct 26, 2022
@parse-github-assistant
Copy link

I will reformat the title to use the proper commit message syntax.

@parse-github-assistant parse-github-assistant bot changed the title fix: File file upload issue fix: file file upload issue Oct 26, 2022
@musthafa1996
Copy link
Contributor Author

Hi @mtrezza! All the test cases are now passing. File uploading works now.
image
image

The overriding of Parse SDK using the git repo git@github.com:musthafa1996/Parse-SDK-JS.git#file-upload-issue for Parse server was necessary to make sure Parse Server uses the Parse SDK with the file upload fix.

Once approved we’ll need to do the following:

  • Remove overriding of Parse SDK for Parse Server
  • Rollback the content of package-lock.json
  • Make sure Parse Server uses the Parse SDK with file upload fix.

@musthafa1996
Copy link
Contributor Author

I have also replaced the Parse SDK overriding repo ssh URL to https repo URL to avoid build issues in CI.
Screenshot 2022-10-31 at 7 24 31 PM

@mtrezza mtrezza changed the title fix: file file upload issue fix: file upload issue Oct 31, 2022
@mtrezza mtrezza changed the title fix: file upload issue fix: file upload fails when uploading base64 data Oct 31, 2022
@mtrezza
Copy link
Member

mtrezza commented Oct 31, 2022

Great, could you solve the conflict so we can see whether the CI passes? I think the next step then would be to revert the changes in package and package-lock and commit the fix, right?

@musthafa1996
Copy link
Contributor Author

I've resolved the conflicts @mtrezza.
Yes, the next step would be to revert the changes in package and package-lock.

@musthafa1996
Copy link
Contributor Author

musthafa1996 commented Oct 31, 2022

@mtrezza, did you just run the CI. Looks like the old SSH repo URL (git@github.com:musthafa1996/Parse-SDK-JS.git#file-upload-issue) was being used instead of HTTPS repo URL (git+https://github.com/musthafa1996/Parse-SDK-JS.git#file-upload-issue). Is there a way we can ensue the latter is used?
image

@mtrezza
Copy link
Member

mtrezza commented Oct 31, 2022

Is the change necessary for this PR? If not, let's keep it as is and revert any changes made in package and package-lock.

@musthafa1996
Copy link
Contributor Author

@mtrezza, did you just run the CI. Looks like the old SSH repo URL (git@github.com:musthafa1996/Parse-SDK-JS.git#file-upload-issue) was being used instead of HTTPS repo URL (git+https://github.com/musthafa1996/Parse-SDK-JS.git#file-upload-issue). Is there a way we can ensue the latter is used? image

This change is necessary. Otherwise you'll keep getting Permission denied error while accessing the git repo.

@mtrezza
Copy link
Member

mtrezza commented Oct 31, 2022

Can you try reverting the package and package-lock please

@mtrezza
Copy link
Member

mtrezza commented Oct 31, 2022

Also, I noticed that there is no test in the JS SDK for this change. Is it possible to add a test that fails without the change?

@musthafa1996
Copy link
Contributor Author

You mean reverting the overrides for Parse SDK too?

@mtrezza
Copy link
Member

mtrezza commented Oct 31, 2022

Yes, the only file that this PR should change is src/ParseFile.js. And possibly a test file if we add a test.

@musthafa1996
Copy link
Contributor Author

Also, I noticed that there is no test in the JS SDK for this change. Is it possible to add a test that fails without the change?

The failing test case wouldn't be possible unless you force Parse server to use the latest alpha version of the Parse SDK. The issue was induce in the recent updates to Parse SDK.

Copy link
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

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

If this was not a lint change, we should also keep this line as is

src/ParseFile.js Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Nov 3, 2022

Codecov Report

Base: 99.93% // Head: 99.93% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (8cfeee5) compared to base (8f94427).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##            alpha    #1578   +/-   ##
=======================================
  Coverage   99.93%   99.93%           
=======================================
  Files          61       61           
  Lines        5963     5966    +3     
  Branches     1364     1366    +2     
=======================================
+ Hits         5959     5962    +3     
  Misses          4        4           
Impacted Files Coverage Δ
src/ParseFile.js 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@mtrezza
Copy link
Member

mtrezza commented Nov 3, 2022

Great, so if you now removed the fix, the tests would fail, even without the override of Parse Server, correct?

@musthafa1996
Copy link
Contributor Author

Great, so without the fix, the tests would now fail, even without the override of Parse Server, correct?

Yes, that’s right.

@mtrezza
Copy link
Member

mtrezza commented Nov 3, 2022

@dplewis Not sure about the override suggestion maybe that would just complicate things? I think the sustainable solution is to move all into a monorepo. We are planning to do that in 2023. For this PR, all looks good now.

@musthafa1996
Copy link
Contributor Author

Anything pending here?

@musthafa1996 musthafa1996 requested a review from dplewis November 3, 2022 10:57
@dplewis
Copy link
Member

dplewis commented Nov 3, 2022

@musthafa1996 I added a few more tests. @mtrezza I think this is ready for review

@musthafa1996
Copy link
Contributor Author

musthafa1996 commented Nov 3, 2022

Any idea why we get this error in Github CI?
85E715BE-A238-4F1A-8341-BF8A9090E8F7

@musthafa1996
Copy link
Contributor Author

Rerunning the CI multiple times would get the integration test to succeed.

@dplewis
Copy link
Member

dplewis commented Nov 3, 2022

@musthafa1996 Its a flaky test should be fixed when parse-community/parse-server#8232 gets merged in. Just reran the tests and everything checked out

@musthafa1996
Copy link
Contributor Author

Got it. Thanks 😊

Copy link
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

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

Thanks everyone, looks good!

@mtrezza mtrezza merged commit 03ee3ff into parse-community:alpha Nov 3, 2022
parseplatformorg pushed a commit that referenced this pull request Nov 3, 2022
# [3.5.0-alpha.8](3.5.0-alpha.7...3.5.0-alpha.8) (2022-11-03)

### Bug Fixes

* File upload fails when uploading base64 data ([#1578](#1578)) ([03ee3ff](03ee3ff))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 3.5.0-alpha.8

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Nov 3, 2022
@dplewis dplewis deleted the file-upload-issue branch November 3, 2022 19:30
@dplewis
Copy link
Member

dplewis commented Nov 3, 2022

@musthafa1996 Thank you for looking into this _data was supposed to be internal on the JS side. I didn't know it was used on the server side. I'll add an addtional check and performance improvements on the server side

@musthafa1996
Copy link
Contributor Author

I’m glad that i could help fix the issue 😊

@musthafa1996
Copy link
Contributor Author

The issue was kind of tricky to find too due to parse server using an older version of the SDK. I’m really looking forward to mono-repo. Development and bug finding will be much easier.

parseplatformorg pushed a commit that referenced this pull request Nov 3, 2022
## [3.5.1-beta.1](3.5.0...3.5.1-beta.1) (2022-11-03)

### Bug Fixes

* File upload fails when uploading base64 data ([#1578](#1578)) ([03ee3ff](03ee3ff))
* React Native build does not maintain arrow functions and causes error with AsyncStorage ([#1587](#1587)) ([8aeaa4f](8aeaa4f))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 3.5.1-beta.1

@parseplatformorg parseplatformorg added the state:released-beta Released as beta version label Nov 3, 2022
parseplatformorg pushed a commit that referenced this pull request Nov 3, 2022
## [3.5.1-alpha.1](3.5.0...3.5.1-alpha.1) (2022-11-03)

### Bug Fixes

* File upload fails when uploading base64 data ([#1578](#1578)) ([03ee3ff](03ee3ff))
* React Native build does not maintain arrow functions and causes error with AsyncStorage ([#1587](#1587)) ([8aeaa4f](8aeaa4f))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 3.5.1-alpha.1

parseplatformorg pushed a commit that referenced this pull request Nov 26, 2022
## [3.5.1](3.5.0...3.5.1) (2022-11-26)

### Bug Fixes

* File upload fails when uploading base64 data ([#1578](#1578)) ([03ee3ff](03ee3ff))
* React Native build does not maintain arrow functions and causes error with AsyncStorage ([#1587](#1587)) ([8aeaa4f](8aeaa4f))
* SDK builds incorrectly since release 3.5.0 causing various bugs ([#1600](#1600)) ([f15154f](f15154f))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 3.5.1

@parseplatformorg parseplatformorg added the state:released Released as stable version label Nov 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue uploading files
4 participants