Skip to content

Commit 4f1882e

Browse files
committed
fix(09.2): read tunnel label from the relay's tags field
Live smoke: picker showed 'No Vector-agent tunnels yet' though the agent's tunnel was listed and hosting. The relay returns the label under `tags`, not `labels` (the SDK maps Tunnel.labels -> tags in the default api-version), so TunnelRecord.labels deserialized empty and is_vector_agent() was always false. Add `#[serde(alias = "tags")]` so labels reads either key; make the list fixture realistic (`tags`). Regression test deserializes a real-shaped record.
1 parent 9420105 commit 4f1882e

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

crates/vector-tunnels/src/model.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ pub struct TunnelRecord {
99
#[serde(rename = "tunnelId")]
1010
pub tunnel_id: String,
1111
pub name: Option<String>,
12-
#[serde(default)]
12+
// The live relay returns this under `tags`; newer api-versions use `labels`.
13+
#[serde(default, alias = "tags")]
1314
pub labels: Vec<String>,
1415
#[serde(rename = "endpoints", default)]
1516
pub endpoints: Vec<TunnelEndpoint>,
@@ -219,4 +220,14 @@ mod tests {
219220
};
220221
assert!(!t.is_vector_agent());
221222
}
223+
224+
// Regression: the live relay returns the label under `tags`, not `labels`.
225+
#[test]
226+
fn deserializes_tags_field_as_labels() {
227+
let json = r#"{"tunnelId":"silent-book-tphgwm9","name":"","tags":["vector-agent"]}"#;
228+
let t: TunnelRecord = serde_json::from_str(json).expect("parse");
229+
assert!(t.is_vector_agent(), "tags must populate labels");
230+
// name is empty → display falls back to the tunnel id.
231+
assert_eq!(t.display_name(), "silent-book-tphgwm9");
232+
}
222233
}

crates/vector-tunnels/tests/fixtures/dev_tunnels_list.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
"tunnelId": "tunnel-vec-1",
44
"name": "vector-corp-box",
5-
"labels": ["vector-agent", "linux"],
5+
"tags": ["vector-agent", "linux"],
66
"endpoints": [
77
{
88
"hostId": "host-vec-1",
@@ -15,7 +15,7 @@
1515
{
1616
"tunnelId": "tunnel-vec-2",
1717
"name": "vector-home-server",
18-
"labels": ["vector-agent", "personal"],
18+
"tags": ["vector-agent", "personal"],
1919
"endpoints": [
2020
{
2121
"hostId": "host-vec-2",
@@ -28,7 +28,7 @@
2828
{
2929
"tunnelId": "tunnel-code-1",
3030
"name": "code-tunnel-laptop",
31-
"labels": ["code-tunnel"],
31+
"tags": ["code-tunnel"],
3232
"endpoints": [
3333
{
3434
"hostId": "host-code-1",
@@ -41,7 +41,7 @@
4141
{
4242
"tunnelId": "tunnel-misc-1",
4343
"name": "misc-shared",
44-
"labels": [],
44+
"tags": [],
4545
"endpoints": [
4646
{
4747
"hostId": "host-misc-1",
@@ -54,7 +54,7 @@
5454
{
5555
"tunnelId": "tunnel-misc-2",
5656
"name": "demo",
57-
"labels": ["demo"],
57+
"tags": ["demo"],
5858
"endpoints": [
5959
{
6060
"hostId": "host-misc-2",

0 commit comments

Comments
 (0)