Skip to content

fix(upload): Forward-compatible query params#6076

Merged
jjbayer merged 15 commits into
masterfrom
ref/location-forward-compat
Jun 23, 2026
Merged

fix(upload): Forward-compatible query params#6076
jjbayer merged 15 commits into
masterfrom
ref/location-forward-compat

Conversation

@jjbayer

@jjbayer jjbayer commented Jun 10, 2026

Copy link
Copy Markdown
Member

For the sake of forward-compatibility, add an "other" variant to the location query params enum. Instead of denylisting certain keys, like sentry_key, prefix all upload-relevant keys with upload_ such that only those get picked up by the upload service.

Fixes: INGEST-807

@linear-code

linear-code Bot commented Jun 10, 2026

Copy link
Copy Markdown

INGEST-807

Comment on lines +491 to +524
impl<'de> Deserialize<'de> for UploadParams {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
struct UploadParamsVisitor;

impl<'de> serde::de::Visitor<'de> for UploadParamsVisitor {
type Value = UploadParams;

fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("upload query parameters")
}

fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error>
where
A: serde::de::MapAccess<'de>,
{
let mut upload_params = BTreeMap::new();

while let Some(key) = map.next_key::<&str>()? {
if key.starts_with("upload_") {
upload_params.insert(key.to_owned(), map.next_value()?);
} else {
map.next_value::<serde::de::IgnoredAny>()?;
}
}

Ok(UploadParams(upload_params))
}
}

deserializer.deserialize_map(UploadParamsVisitor)
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I added this custom parser to skip over query params that do not start with upload_ (e.g. sentry_key).

@jjbayer jjbayer marked this pull request as ready for review June 11, 2026 19:47
@jjbayer jjbayer requested a review from a team as a code owner June 11, 2026 19:47
Comment thread relay-server/src/services/upload.rs
Comment thread relay-server/src/services/upload.rs
Comment thread relay-server/src/services/upload.rs
Comment thread relay-server/src/services/upload.rs Outdated
Comment thread relay-conventions/sentry-conventions
jjbayer and others added 3 commits June 12, 2026 09:45
Co-authored-by: Sebastian Zivota <loewenheim@users.noreply.github.com>

@elramen elramen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice!

Comment thread relay-server/src/services/upload.rs Outdated
Co-authored-by: elramen <158566966+elramen@users.noreply.github.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 521fa81. Configure here.

Comment thread relay-server/src/services/upload.rs
Comment on lines +771 to +773
RequestKind::Upload { location, .. } => location
.try_to_uri()
.expect("upload location should be serializable"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The path() method uses .expect() on the result of try_to_uri(), which can fail during serialization. This creates an unnecessary panic path instead of propagating the error.
Severity: LOW

Suggested Fix

The UpstreamRequest::path() trait method should be changed to return a Result<Cow<'_, str>, Error>. This would allow propagating the serialization error from try_to_uri() up to the caller in SharedClient::build_request(), where it can be handled gracefully instead of causing a panic.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: relay-server/src/services/upload.rs#L771-L773

Potential issue: The `UploadRequest::path()` method calls `.expect()` on the result of
`try_to_uri()`, which performs URL-encoded serialization that can fail. This pull
request intentionally made `try_to_uri()` fallible by changing its signature to return a
`Result<String, Error>`, but this specific call site was not updated to handle the error
case. A panic here occurs within a synchronous `build_request` context, which will crash
the async task and could lead to a server crash. While serialization of the involved
types is unlikely to fail in practice, using `.expect()` introduces an avoidable panic
path and is inconsistent with the PR's goal of improved error handling.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Will handle in #6120.

@jjbayer jjbayer enabled auto-merge June 23, 2026 08:39
@jjbayer jjbayer added this pull request to the merge queue Jun 23, 2026
Merged via the queue into master with commit 82c1abc Jun 23, 2026
33 checks passed
@jjbayer jjbayer deleted the ref/location-forward-compat branch June 23, 2026 09:51
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