Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions devservices/proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ proxy:
cell_to_upstream:
"--monolith--": sentry-dev-monolith
default: sentry-dev-monolith
- match:
path: /organization-avatar/{organization}/{avatar_id}
action:
resolver: cell_from_organization
cell_to_upstream:
"--monolith--": sentry-dev-monolith
default: sentry-dev-monolith

metrics:
statsd_host: "127.0.0.1"
Expand Down
9 changes: 9 additions & 0 deletions example_config_proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ proxy:
us1: us1-getsentry
us2: us2-getsentry
default: us1-getsentry
- match:
host: us.sentry.io
path: /organization-avatar/{organization}/{avatar_id}
action:
resolver: cell_from_organization
cell_to_upstream:
us1: us1-getsentry
us2: us2-getsentry
default: us1-getsentry
- match:
host: us.sentry.io
path: /api/0/cell/{cell_id}/*
Expand Down
41 changes: 41 additions & 0 deletions proxy/src/route_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,4 +371,45 @@ mod tests {
})
);
}

#[test]
fn test_organization_avatar_slug_locator() {
// route on first segment after static prefix; org avatars are
// served from /organization-avatar/{slug}/{id}
// (the avatar id is captured but ignored)
let config = RouteConfig {
r#match: crate::config::Match {
host: None,
path: Some("/organization-avatar/{organization}/{avatar_id}".to_string()),
},
action: crate::config::Action::Dynamic {
resolver: crate::config::Resolver::CellFromOrganization,
cell_to_upstream: HashMap::new(),
default: None,
},
};

let route = Route::try_from(config.clone()).unwrap();

assert_eq!(
route.matches(None, "/organization-avatar/my-org/abc123/"),
Some(RouteMatch {
params: HashMap::from([
("organization".to_string(), "my-org".to_string()),
("avatar_id".to_string(), "abc123".to_string()),
]),
action: config.action.clone(),
}),
"captures the slug as `organization`, not the avatar id"
);

// the explicit two-segment org segment must not match
// deprecated, slug-less form (/organization-avatar/{id})
assert!(
route
.matches(None, "/organization-avatar/abc123/")
.is_none(),
"deprecated slug-less form must not match the slug locator"
);
}
}
Loading