Version Upload API: Handle \n for release notes #262

Merged
Dalai Felinto merged 2 commits from version-update-linebreak into main 2024-10-10 18:58:14 +02:00

On my tests, when running the API with CURL via command-line the \n
were being converted to string \n, and there would be no way to write a
multi-line release notes.

On my tests, when running the API with CURL via command-line the \n were being converted to string \n, and there would be no way to write a multi-line release notes.
Dalai Felinto added 1 commit 2024-10-10 18:26:46 +02:00
On my tests, when running the API with CURL via command-line the \n
were being converted to string \n, and there would be no way to write a
multi-line release notes.
Author
Owner

For the records, initially the unittest was passing even without my changes. It seems that CURL interprets strings differently than our unittest? It is also possible that I don't know how to test multi-lines with CURL (I tried a few ways, all of them failed, requiring this patch).

For the records, initially the unittest was passing even without my changes. It seems that CURL interprets strings differently than our unittest? It is also possible that I don't know how to test multi-lines with CURL (I tried a few ways, all of them failed, requiring this patch).
Author
Owner

And once (if) this is accepted I will update the documentation to mention \n: https://developer.blender.org/docs/features/extensions/ci_cd/

And once (if) this is accepted I will update the documentation to mention `\n`: https://developer.blender.org/docs/features/extensions/ci_cd/
Francesco Siddi requested changes 2024-10-10 18:40:41 +02:00
Dismissed
@ -175,0 +175,4 @@
def validate_release_notes(self, value):
r"""Make sure \n and \r are valid after sanitation."""
if not value:
return value

why not a simple return?

why not a simple `return`?
Author
Owner

To make sure if we get None we still return None, if we get "" we still return "".

I will change this so it test for None instead.

To make sure if we get None we still return None, if we get "" we still return "". I will change this so it test for None instead.
dfelinto marked this conversation as resolved
Dalai Felinto added 1 commit 2024-10-10 18:47:36 +02:00
Francesco Siddi approved these changes 2024-10-10 18:51:18 +02:00
Dalai Felinto merged commit 3bdf37b6bd into main 2024-10-10 18:58:14 +02:00
Dalai Felinto deleted branch version-update-linebreak 2024-10-10 18:58:14 +02:00
Owner

@dfelinto do you have an example with the curl command you were using that was treated unexpectedly? I suspect that it may be a problem with shell escaping, i.e. that the request processing itself works correctly, but curl is being passed \ and n instead of \n.

I haven't run the code, but do I understand it correctly that now it is impossible to submit release notes that contain a literal \n sequence?
I can imagine someone publishing a release note about a fixed bug of "\n processing fixed" and not being able to do that because of this added change.

@dfelinto do you have an example with the curl command you were using that was treated unexpectedly? I suspect that it may be a problem with shell escaping, i.e. that the request processing itself works correctly, but curl is being passed `\` and `n` instead of `\n`. I haven't run the code, but do I understand it correctly that now it is impossible to submit release notes that contain a literal `\n` sequence? I can imagine someone publishing a release note about a fixed bug of "\n processing fixed" and not being able to do that because of this added change.
Author
Owner

@Oleg-Komarov you are right. I reverted the commit and updated the documentation.

This works well now:

curl -X POST https://extensions.blender.org/api/v1/extensions/my_addon/versions/upload/ \
  -H "Authorization:bearer x_xRe91mBmlHLveA9v-xyKgPcm8Zig2EH7Uhh0vHCN8" \
  -F "version_file=@/home/user/my-addon-1.0.1.zip" \
  -F release_notes=$'* Fix crashes when opening Blender.\n* Improve performance 2x.\n* Fix parsing \\n characters.'

Thanks for keeping an eye on it.

@Oleg-Komarov you are right. I reverted the commit and updated the [documentation](https://developer.blender.org/docs/features/extensions/ci_cd/). This works well now: ``` curl -X POST https://extensions.blender.org/api/v1/extensions/my_addon/versions/upload/ \ -H "Authorization:bearer x_xRe91mBmlHLveA9v-xyKgPcm8Zig2EH7Uhh0vHCN8" \ -F "version_file=@/home/user/my-addon-1.0.1.zip" \ -F release_notes=$'* Fix crashes when opening Blender.\n* Improve performance 2x.\n* Fix parsing \\n characters.' ``` Thanks for keeping an eye on it.
Owner

Thank you!

Thank you!
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: infrastructure/extensions-website#262
No description provided.