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 For When user selects Empty files using File Upload #3051

Merged
merged 3 commits into from Apr 11, 2024

Conversation

Yummy-Yums
Copy link
Contributor

@Yummy-Yums Yummy-Yums commented Apr 9, 2024

All Submissions:

  • Have you followed the guidelines stated in CONTRIBUTING.md file?
  • Have you checked to ensure there aren't any other open Pull Requests for the desired changed?

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

New Feature Submission:

  • Does your submission pass the tests?
  • Have you linted your code locally prior to submission?

Changes To Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

After these steps, you're ready to open a pull request.

a. Give a descriptive title to your PR.

b. Describe your changes.

c. Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if such).

@Yummy-Yums
Copy link
Contributor Author

#2873


if (event.payload.files === undefined || event.payload.files.length === 0){
// Submit the event over the websocket to trigger the event handler.
return await applyEvent(Event(event.name, event.payload.files), socket)
Copy link
Collaborator

Choose a reason for hiding this comment

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

the payload is supposed to be a object, not an array

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you mean return await applyEvent(Event(event.name, event.payload), socket)

Copy link
Collaborator

Choose a reason for hiding this comment

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

the problem is that event.payload contains keys that do not map to an arbitrary event handler on the backend.

for example, maybe it works if the backend event handler has a files arg; but if that arg is named fools, then we get an error on the backend about unknown keyword argument.

@Yummy-Yums Yummy-Yums requested a review from masenf April 9, 2024 17:08
@@ -381,7 +387,7 @@ export const uploadFiles = async (
) => {
// return if there's no file to upload
if (files === undefined || files.length === 0) {
return false;
files = []
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is this change doing? if we end up hitting this code, won't it ultimately throw that "Did not find CR at end of boundary (40)" error in the upload handler?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

correct, resolved it

@Yummy-Yums Yummy-Yums requested a review from masenf April 9, 2024 18:33
Copy link
Collaborator

@masenf masenf left a comment

Choose a reason for hiding this comment

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

the only thing that still makes me nervous about this is that, if the handler doesn't specify a default for the list[rx.UploadFile] arg, then there will be a traceback printed on the backend, whereas before, this was just a no op.

i think that's okay though. it will still be a no-op, and if they want to avoid the traceback, they can add a default value...

@Yummy-Yums
Copy link
Contributor Author

the only thing that still makes me nervous about this is that, if the handler doesn't specify a default for the list[rx.UploadFile] arg, then there will be a traceback printed on the backend, whereas before, this was just a no op.

i think that's okay though. it will still be a no-op, and if they want to avoid the traceback, they can add a default value...

i think we can put it in a doc somewhere ? or leave it like that? what dyu suggest ?

@picklelo picklelo merged commit 6837eb8 into reflex-dev:main Apr 11, 2024
46 checks passed
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.

None yet

3 participants