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(server): more asset upload validation and docs #1720

Merged
merged 8 commits into from
Feb 12, 2023
Merged

fix(server): more asset upload validation and docs #1720

merged 8 commits into from
Feb 12, 2023

Conversation

michelheusschen
Copy link
Contributor

I've made some changes to the /asset/upload endpoint in order to add proper validation. Before these changes, the assetType enum could be set to an arbitrary value and the assetData was allowed to be empty. Now, assetType will only accept values defined in the enum and assetData will be required. I've also added missing API documentation to the endpoint.

This was my first time working with NestJS, so feedback is welcome.

@vercel
Copy link

vercel bot commented Feb 10, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
immich-code-coverage ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 12, 2023 at 5:27AM (UTC)
1 Ignored Deployment
Name Status Preview Comments Updated
immich ⬜️ Ignored (Inspect) Feb 12, 2023 at 5:27AM (UTC)

@vercel vercel bot temporarily deployed to Preview – immich-code-coverage February 10, 2023 09:07 Inactive
@alextran1502 alextran1502 requested a review from jrasm91 February 10, 2023 14:56
Copy link
Contributor

@jrasm91 jrasm91 left a comment

Choose a reason for hiding this comment

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

The new validation looks great! Thanks for the contribution, just a few comments about some possible simplification.

@vercel vercel bot temporarily deployed to Preview – immich-code-coverage February 10, 2023 15:34 Inactive
@vercel vercel bot temporarily deployed to Preview – immich-code-coverage February 10, 2023 17:55 Inactive
@jrasm91
Copy link
Contributor

jrasm91 commented Feb 10, 2023

Regarding the issue with the enum. This looks to be specifically related to our enum/object type being used in a form. I'd really rather not do another custom patch, if it can be avoided. I'm happy to have this enum be { enum } to avoid the weirdness with the form data and keep the implementation simple/clean.

@jrasm91
Copy link
Contributor

jrasm91 commented Feb 10, 2023

Seems related: OpenAPITools/openapi-generator#13880

@jrasm91
Copy link
Contributor

jrasm91 commented Feb 10, 2023

Are you on the immich discord by chance?

@jrasm91
Copy link
Contributor

jrasm91 commented Feb 10, 2023

Looking at the patch some more, I think it's an actual bug in the generator that should be fixed in the upstream repo. I'm fine either way (patch or reverting to inline-enum), but it would be nice to get this fixed upstream if possible.

OpenAPITools/openapi-generator#10729

@michelheusschen
Copy link
Contributor Author

An upstream fix would be the ideal solution, but the amount of open issues and PRs are scary. The bug seems to be introduced in OpenAPITools/openapi-generator#7816 as suggested. I tried using the template file before that PR got merged, but several other improvements and fixes have been made since so it's not worth it IMO.

I'm good with leaving it like this, unless you want the custom template removed.

Copy link
Contributor

@jrasm91 jrasm91 left a comment

Choose a reason for hiding this comment

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

Also happy with it 👍

@alextran1502
Copy link
Contributor

Looks good, can you help resolve the conflict in this PR?

@vercel vercel bot temporarily deployed to Preview – immich-code-coverage February 12, 2023 05:16 Inactive
@michelheusschen
Copy link
Contributor Author

Done

@vercel vercel bot temporarily deployed to Preview – immich-code-coverage February 12, 2023 05:27 Inactive
@alextran1502 alextran1502 merged commit 0563077 into immich-app:main Feb 12, 2023
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.

3 participants