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

Add support for API blob upload of release attachments #29507

Merged
merged 6 commits into from
Mar 2, 2024

Conversation

KN4CK3R
Copy link
Member

@KN4CK3R KN4CK3R commented Feb 29, 2024

@KN4CK3R KN4CK3R added the type/enhancement An improvement of existing functionality label Feb 29, 2024
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 29, 2024
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 29, 2024
@github-actions github-actions bot added the modifies/api This PR adds API routes or modifies them label Feb 29, 2024
@KN4CK3R
Copy link
Member Author

KN4CK3R commented Feb 29, 2024

Ready for review after adding a test.

@delvh delvh changed the title Add support for blob upload Add support for API blob upload of release attachment Feb 29, 2024
@delvh delvh changed the title Add support for API blob upload of release attachment Add support for API blob upload of release attachments Feb 29, 2024
@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 1, 2024
@delvh delvh marked this pull request as ready for review March 1, 2024 11:54
defer tests.PrintCurrentTest(t)()

req := NewRequestWithBody(t, http.MethodPost, assetURL, bytes.NewReader(buff.Bytes())).
AddTokenAuth(token)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
AddTokenAuth(token)
AddTokenAuth(token)
SetHeader("Content-Type", "application/octet-stream")

Just so we test what is specced.

Copy link
Member Author

@KN4CK3R KN4CK3R Mar 2, 2024

Choose a reason for hiding this comment

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

Use the required Content-Type header to provide the media type of the asset. For a list of media types, see Media Types. For example:

application/zip

That's not specced. The Github docs state that you must pass the content type of the attachment. We do not use the content type, therefore application/octet-stream is not really needed. If we want to make that header required too (even we don't use it), I need to add such a check.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe adding a check is better.

Copy link
Member

@silverwind silverwind Mar 2, 2024

Choose a reason for hiding this comment

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

Right, we accept any content-type except multipart, so it's fine. I suppose GitHub will error when content-type is absent, but we can do that, I see no drawback.

Copy link
Member

Choose a reason for hiding this comment

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

BTW, with openapi 3.0 or higher, one could do a oneOf check on content-type in the schema validation, but we use swagger 2.0 and it does not support that.

We should eventually migrate to ideally openapi 3.1, but it will require a new validator module.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Mar 1, 2024
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 2, 2024
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 2, 2024
@lunny lunny added this to the 1.22.0 milestone Mar 2, 2024
@lunny lunny enabled auto-merge (squash) March 2, 2024 09:09
@lunny lunny disabled auto-merge March 2, 2024 09:29
@lunny lunny removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 2, 2024
@silverwind silverwind enabled auto-merge (squash) March 2, 2024 16:32
@silverwind silverwind added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 2, 2024
@silverwind silverwind merged commit 70c126e into go-gitea:main Mar 2, 2024
26 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 2, 2024
@KN4CK3R KN4CK3R deleted the enhancement-release branch March 2, 2024 17:10
zjjhot added a commit to zjjhot/gitea that referenced this pull request Mar 3, 2024
* upstream/main:
  Breaking summary for template refactoring (go-gitea#29395)
  [skip ci] Updated translations via Crowdin
  Fix incorrect cookie path for AppSubURL (go-gitea#29534)
  gitea.service: Remove syslog.target (go-gitea#29550)
  Add option to set language in admin user view (go-gitea#28449)
  Fix elipsis button not working if the last commit loading is deferred (go-gitea#29544)
  Fix incorrect relative/absolute URL usages (go-gitea#29531)
  Add support for API blob upload of release attachments (go-gitea#29507)
  Fix queue worker incorrectly stopped when there are still more items in the queue (go-gitea#29532)
  remove util.OptionalBool and related functions (go-gitea#29513)
  Rename Action.GetDisplayName to GetActDisplayName (go-gitea#29540)
  Make PR form use toast to show error message (go-gitea#29545)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/api This PR adds API routes or modifies them size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API: POST releases/{id}/assets should accept application/octet-stream
6 participants