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

TypeError in upload_image – No response returned for image uploads #75

Closed
01bps opened this issue Feb 17, 2025 · 14 comments
Closed

TypeError in upload_image – No response returned for image uploads #75

01bps opened this issue Feb 17, 2025 · 14 comments

Comments

@01bps
Copy link
Contributor

01bps commented Feb 17, 2025

I ran into a TypeError while uploading images, but it doesn't seem to affect PDFs. From what I understand, the function might not always return a response in certain cases.

@mdxabu , can you check if you're experiencing this too? If so, I'd be happy to fix it.

@mdxabu
Copy link
Member

mdxabu commented Feb 17, 2025

I ran into a TypeError while uploading images, but it doesn't seem to affect PDFs. From what I understand, the function might not always return a response in certain cases.

@mdxabu , can you check if you're experiencing this too? If so, I'd be happy to fix it.

Sorry, I can't understand what you're mentioning. Can you elaborate?

@01bps
Copy link
Contributor Author

01bps commented Feb 17, 2025

I encountered the TypeError while uploading images, specifically when I tried to upload an image file(png).(on the dev branch)
i.e TypeError: The view function for 'upload_image' did not return a valid response.
It seems the function may not have a return statement after processing the image upload.

@01bps
Copy link
Contributor Author

01bps commented Feb 18, 2025

@mdxabu ,Just following up—did you also encounter the TypeError while uploading images (PNG or any format except for PDF) on the dev branch? Let me know if you need more details.
Thanks!

@ishaanxgupta
Copy link
Contributor

@mdxabu ,Just following up—did you also encounter the TypeError while uploading images (PNG or any format except for PDF) on the dev branch? Let me know if you need more details. Thanks!

Yes this is a valid issue I just checked there was no return statement with the upload image function on the backend that is why was giving this error. I have rectified this in PR #76

@01bps
Copy link
Contributor Author

01bps commented Feb 18, 2025

@mdxabu ,Just following up—did you also encounter the TypeError while uploading images (PNG or any format except for PDF) on the dev branch? Let me know if you need more details. Thanks!

Yes this is a valid issue I just checked there was no return statement with the upload image function on the backend that is why was giving this error. I have rectified this in PR #76

I had already resolved this in my local repository and was waiting for a confirmation from @mdxabu before opening a PR, to check if the issue was widespread or just on my end.Moving forward, I believe it would be more efficient to discuss such issues here first before opening a PR to ensure alignment and avoid duplicate efforts.

@mdxabu
Copy link
Member

mdxabu commented Feb 18, 2025

@mdxabu ,Just following up—did you also encounter the TypeError while uploading images (PNG or any format except for PDF) on the dev branch? Let me know if you need more details. Thanks!

Yes this is a valid issue I just checked there was no return statement with the upload image function on the backend that is why was giving this error. I have rectified this in PR #76

I had already resolved this in my local repository and was waiting for a confirmation from @mdxabu before opening a PR, to check if the issue was widespread or just on my end.Moving forward, I believe it would be more efficient to discuss such issues here first before opening a PR to ensure alignment and avoid duplicate efforts.

Sorry for the late reply @01bps Please tell me the entire issue you are facing in the backend, and I'll review it also I can open some issues from tomorrow, so I think there will be no conflict will happen 👍🏽 . Interested people can show their interest.

Regards,
Mohamed Abdullah

@01bps
Copy link
Contributor Author

01bps commented Feb 18, 2025

@mdxabu ,Just following up—did you also encounter the TypeError while uploading images (PNG or any format except for PDF) on the dev branch? Let me know if you need more details. Thanks!

Yes this is a valid issue I just checked there was no return statement with the upload image function on the backend that is why was giving this error. I have rectified this in PR #76

I had already resolved this in my local repository and was waiting for a confirmation from @mdxabu before opening a PR, to check if the issue was widespread or just on my end.Moving forward, I believe it would be more efficient to discuss such issues here first before opening a PR to ensure alignment and avoid duplicate efforts.

Sorry for the late reply @01bps Please tell me the entire issue you are facing in the backend, and I'll review it also I can open some issues from tomorrow, so I think there will be no conflict will happen 👍🏽 . Interested people can show their interest.

Regards, Mohamed Abdullah

No worries, @mdxabu! I appreciate your response.

The issue I encountered was a TypeError where, if an image (JPG, PNG, etc.) was uploaded instead of a PDF, the function didn’t return a response after saving the file.

The if filename.lower().endswith('.pdf'): block correctly handles PDFs by processing the file and then redirecting.
However, for non-PDF files, the function simply stops after saving the file without returning anything, leading to an issue.
i.e,

Image

To address this, I made the following changes:

  1. Added a return redirect for non-PDF files – Previously, non-PDF files were saved, but the function didn’t return a response. I added a redirect to the profile page to ensure proper handling.

I also thought of adding these but Since our web app already ensures that an image won’t be uploaded unless all required fields (image, title, and description) are provided, setting default values might not be necessary.
However, if needed, we could still define defaults to prevent potential errors when fields like image, title or description are missing.

  1. Using .get() for request.files['file'] and Set Default Values for request.form.get(): – This prevents a KeyError if no file is uploaded, improving error handling.

@mdxabu
Copy link
Member

mdxabu commented Feb 18, 2025

@mdxabu ,Just following up—did you also encounter the TypeError while uploading images (PNG or any format except for PDF) on the dev branch? Let me know if you need more details. Thanks!

Yes this is a valid issue I just checked there was no return statement with the upload image function on the backend that is why was giving this error. I have rectified this in PR #76

I had already resolved this in my local repository and was waiting for a confirmation from @mdxabu before opening a PR, to check if the issue was widespread or just on my end.Moving forward, I believe it would be more efficient to discuss such issues here first before opening a PR to ensure alignment and avoid duplicate efforts.

Sorry for the late reply @01bps Please tell me the entire issue you are facing in the backend, and I'll review it also I can open some issues from tomorrow, so I think there will be no conflict will happen 👍🏽 . Interested people can show their interest.

Regards, Mohamed Abdullah

No worries, @mdxabu! I appreciate your response.

The issue I encountered was a TypeError where, if an image (JPG, PNG, etc.) was uploaded instead of a PDF, the function didn’t return a response after saving the file.

The if filename.lower().endswith('.pdf'): block correctly handles PDFs by processing the file and then redirecting.
However, for non-PDF files, the function simply stops after saving the file without returning anything, leading to an issue.
i.e,

Image

To address this, I made the following changes:

  1. Added a return redirect for non-PDF files – Previously, non-PDF files were saved, but the function didn’t return a response. I added a redirect to the profile page to ensure proper handling.

I also thought of adding these but Since our web app already ensures that an image won’t be uploaded unless all required fields (image, title, and description) are provided, setting default values might not be necessary.
However, if needed, we could still define defaults to prevent potential errors when fields like image, title or description are missing.

  1. Using .get() for request.files['file'] and Set Default Values for request.form.get(): – This prevents a KeyError if no file is uploaded, improving error handling.

Before implementing'PDF' files, It works fine. I'll test and fix this issue.

@01bps
Copy link
Contributor Author

01bps commented Feb 18, 2025

@mdxabu ,Just following up—did you also encounter the TypeError while uploading images (PNG or any format except for PDF) on the dev branch? Let me know if you need more details. Thanks!

Yes this is a valid issue I just checked there was no return statement with the upload image function on the backend that is why was giving this error. I have rectified this in PR #76

I had already resolved this in my local repository and was waiting for a confirmation from @mdxabu before opening a PR, to check if the issue was widespread or just on my end.Moving forward, I believe it would be more efficient to discuss such issues here first before opening a PR to ensure alignment and avoid duplicate efforts.

Sorry for the late reply @01bps Please tell me the entire issue you are facing in the backend, and I'll review it also I can open some issues from tomorrow, so I think there will be no conflict will happen 👍🏽 . Interested people can show their interest.
Regards, Mohamed Abdullah

No worries, @mdxabu! I appreciate your response.
The issue I encountered was a TypeError where, if an image (JPG, PNG, etc.) was uploaded instead of a PDF, the function didn’t return a response after saving the file.
The if filename.lower().endswith('.pdf'): block correctly handles PDFs by processing the file and then redirecting.
However, for non-PDF files, the function simply stops after saving the file without returning anything, leading to an issue.
i.e,
Image
To address this, I made the following changes:

  1. Added a return redirect for non-PDF files – Previously, non-PDF files were saved, but the function didn’t return a response. I added a redirect to the profile page to ensure proper handling.

I also thought of adding these but Since our web app already ensures that an image won’t be uploaded unless all required fields (image, title, and description) are provided, setting default values might not be necessary.
However, if needed, we could still define defaults to prevent potential errors when fields like image, title or description are missing.

  1. Using .get() for request.files['file'] and Set Default Values for request.form.get(): – This prevents a KeyError if no file is uploaded, improving error handling.

Before implementing'PDF' files, It works fine. I'll test and fix this issue.

Sure! Thanks for looking into it. Let me know if you need any further details from my end.

@ishaanxgupta
Copy link
Contributor

more efficient to discuss such issues here first before opening a PR to ensure alignment and avoid duplicate efforts.

I am sorry for the misunderstanding. I thought that if this issue was created by my previous PR I should have taken the responsibility to resolve this as this should not be a burden for other contributors. If my PR discourages the very spirit of open source, i will close it, you can raise a PR for this issue

@ishaanxgupta
Copy link
Contributor

@mdxabu ,Just following up—did you also encounter the TypeError while uploading images (PNG or any format except for PDF) on the dev branch? Let me know if you need more details. Thanks!

Yes this is a valid issue I just checked there was no return statement with the upload image function on the backend that is why was giving this error. I have rectified this in PR #76

I had already resolved this in my local repository and was waiting for a confirmation from @mdxabu before opening a PR, to check if the issue was widespread or just on my end.Moving forward, I believe it would be more efficient to discuss such issues here first before opening a PR to ensure alignment and avoid duplicate efforts.

Sorry for the late reply @01bps Please tell me the entire issue you are facing in the backend, and I'll review it also I can open some issues from tomorrow, so I think there will be no conflict will happen 👍🏽 . Interested people can show their interest.
Regards, Mohamed Abdullah

No worries, @mdxabu! I appreciate your response.

The issue I encountered was a TypeError where, if an image (JPG, PNG, etc.) was uploaded instead of a PDF, the function didn’t return a response after saving the file.

The if filename.lower().endswith('.pdf'): block correctly handles PDFs by processing the file and then redirecting. However, for non-PDF files, the function simply stops after saving the file without returning anything, leading to an issue. i.e,

Image

To address this, I made the following changes:

  1. Added a return redirect for non-PDF files – Previously, non-PDF files were saved, but the function didn’t return a response. I added a redirect to the profile page to ensure proper handling.

I also thought of adding these but Since our web app already ensures that an image won’t be uploaded unless all required fields (image, title, and description) are provided, setting default values might not be necessary. However, if needed, we could still define defaults to prevent potential errors when fields like image, title or description are missing.

  1. Using .get() for request.files['file'] and Set Default Values for request.form.get(): – This prevents a KeyError if no file is uploaded, improving error handling.

absolutely correct, i did these changes only for issue to be resolved

@ishaanxgupta
Copy link
Contributor

@mdxabu ,Just following up—did you also encounter the TypeError while uploading images (PNG or any format except for PDF) on the dev branch? Let me know if you need more details. Thanks!

Yes this is a valid issue I just checked there was no return statement with the upload image function on the backend that is why was giving this error. I have rectified this in PR #76

I had already resolved this in my local repository and was waiting for a confirmation from @mdxabu before opening a PR, to check if the issue was widespread or just on my end.Moving forward, I believe it would be more efficient to discuss such issues here first before opening a PR to ensure alignment and avoid duplicate efforts.

Sorry for the late reply @01bps Please tell me the entire issue you are facing in the backend, and I'll review it also I can open some issues from tomorrow, so I think there will be no conflict will happen 👍🏽 . Interested people can show their interest.

Regards, Mohamed Abdullah

Sure also apart from this issue, should I make #65 for main branch also?

@mdxabu
Copy link
Member

mdxabu commented Feb 18, 2025

more efficient to discuss such issues here first before opening a PR to ensure alignment and avoid duplicate efforts.

I am sorry for the misunderstanding. I thought that if this issue was created by my previous PR I should have taken the responsibility to resolve this as this should not be a burden for other contributors. If my PR discourages the very spirit of open source, i will close it, you can raise a PR for this issue

Thanks for understanding. Happy open source ❤️

@01bps
Copy link
Contributor Author

01bps commented Feb 18, 2025

more efficient to discuss such issues here first before opening a PR to ensure alignment and avoid duplicate efforts.

I am sorry for the misunderstanding. I thought that if this issue was created by my previous PR I should have taken the responsibility to resolve this as this should not be a burden for other contributors. If my PR discourages the very spirit of open source, i will close it, you can raise a PR for this issue

No worries. Let's move forward and resolve this. Thanks for your understanding, and feel free to continue with the contributions!
And yes, happy open source.

@01bps 01bps closed this as completed Feb 21, 2025
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

No branches or pull requests

3 participants