-
Notifications
You must be signed in to change notification settings - Fork 117
fix(minidump): Streaming uploads from external relays #5977
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
258008a
test(minidump): Upload from external
jjbayer 446608b
types
jjbayer ead27e7
untrust
jjbayer eb07686
Merge remote-tracking branch 'origin/master' into test/minidump-external
jjbayer d121d95
fix
jjbayer 3081790
fix: deserialize
jjbayer 3728a42
Merge remote-tracking branch 'origin/master' into test/minidump-external
jjbayer 086aa74
ref
jjbayer af63465
changelog
jjbayer 0fbc612
fix changelog
jjbayer 2d181f1
simplify
jjbayer d60db31
update integration test
jjbayer 66d2616
use serde_urlencoded in tests
jjbayer 23f6990
rm dead code
jjbayer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,9 @@ use crate::service::ServiceState; | |
| #[cfg(feature = "processing")] | ||
| use crate::services::objectstore; | ||
| use crate::services::projects::cache::Project; | ||
| use crate::services::upload::{self, ByteStream, SignedLocation}; | ||
| use crate::services::upload::{ | ||
| self, ByteStream, Final, LocationQueryParams, Provisional, SignedLocation, UploadLength, | ||
| }; | ||
| use crate::services::upstream::UpstreamRequestError; | ||
| use crate::statsd::RelayCounters; | ||
| use crate::utils::{ApiErrorResponse, MeteredStream}; | ||
|
|
@@ -76,7 +78,6 @@ impl IntoResponse for Error { | |
| } | ||
|
|
||
| let status = match self { | ||
| Error::Tus(tus::Error::DeferLengthNotAllowed) => StatusCode::FORBIDDEN, | ||
| Error::Tus(_) => StatusCode::BAD_REQUEST, | ||
| Error::Request(error) => return error.into_response(), | ||
| Error::SendError(_) => StatusCode::INTERNAL_SERVER_ERROR, | ||
|
|
@@ -129,7 +130,7 @@ impl IntoResponse for Error { | |
| } | ||
| } | ||
|
|
||
| impl IntoResponse for SignedLocation { | ||
| impl<L: UploadLength> IntoResponse for SignedLocation<L> { | ||
| fn into_response(self) -> Response { | ||
| let mut headers = tus::response_headers(); | ||
| match self.into_header_value() { | ||
|
|
@@ -153,8 +154,7 @@ async fn handle_post( | |
| check_kill_switch(&state)?; | ||
|
|
||
| relay_log::trace!("Validating headers"); | ||
| let upload_length = tus::validate_post_headers(&headers, meta.request_trust().is_trusted()) | ||
| .map_err(Error::from)?; | ||
| let upload_length = tus::validate_post_headers(&headers).map_err(Error::from)?; | ||
| let config = state.config(); | ||
|
|
||
| if upload_length.is_some_and(|len| len > config.max_upload_size()) { | ||
|
|
@@ -177,6 +177,7 @@ async fn handle_post( | |
| let scoping = check_request(&state, meta, upload_length, project).await?; | ||
|
|
||
| // Unconditionally create the upload location: | ||
| relay_log::trace!("Creating upload location"); | ||
| let result = create(&state, scoping, upload_length).await; | ||
| let location = result.inspect_err(|e| { | ||
| relay_log::warn!(error = e as &dyn std::error::Error, "create failed"); | ||
|
|
@@ -195,7 +196,7 @@ async fn handle_patch( | |
| meta: RequestMeta, | ||
| headers: HeaderMap, | ||
| Path(upload::LocationPath { project_id, key }): Path<upload::LocationPath>, | ||
| Query(upload::LocationQueryParams { length, signature }): Query<upload::LocationQueryParams>, | ||
| Query(LocationQueryParams { length, signature }): Query<LocationQueryParams<Provisional>>, | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Introducing the differentiation between |
||
| body: Body, | ||
| ) -> axum::response::Result<impl IntoResponse> { | ||
| check_kill_switch(&state)?; | ||
|
|
@@ -220,15 +221,15 @@ async fn handle_patch( | |
| })?; | ||
|
|
||
| relay_log::trace!("Checking request"); | ||
| let scoping = check_request(&state, meta, length, project).await?; | ||
| let scoping = check_request(&state, meta, length.value(), project).await?; | ||
|
|
||
| let stream = body | ||
| .into_data_stream() | ||
| .map(|result| result.map_err(io::Error::other)) | ||
| .boxed(); | ||
| let stream = MeteredStream::new(stream, "upload"); | ||
|
|
||
| let (lower_bound, upper_bound) = match length { | ||
| let (lower_bound, upper_bound) = match length.value() { | ||
| None => (1, config.max_upload_size()), | ||
| Some(u) => (u, u), | ||
| }; | ||
|
|
@@ -282,7 +283,7 @@ async fn create( | |
| state: &ServiceState, | ||
| scoping: Scoping, | ||
| upload_length: Option<usize>, | ||
| ) -> Result<SignedLocation, Error> { | ||
| ) -> Result<SignedLocation<Provisional>, Error> { | ||
| let location = state | ||
| .upload() | ||
| .send(upload::Create { | ||
|
|
@@ -297,9 +298,9 @@ async fn create( | |
| async fn upload( | ||
| state: &ServiceState, | ||
| scoping: Scoping, | ||
| location: SignedLocation, | ||
| location: SignedLocation<Provisional>, | ||
| stream: BoundedStream<MeteredStream<ByteStream>>, | ||
| ) -> Result<SignedLocation, Error> { | ||
| ) -> Result<SignedLocation<Final>, Error> { | ||
| let location = state | ||
| .upload() | ||
| .send(upload::Stream { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the functional change of this PR: We now always allow the
Defer-Length: 1header (i.e. open-ended uploads for which the length is unknown upfront). Correct rate limiting is guaranteed by theSignedLocation<Final>type.