Skip to content
This repository was archived by the owner on Jan 2, 2025. It is now read-only.

Commit 52172f0

Browse files
committed
Fix link offset loop
Previously, the logic to check child elements was using `.any`, and thus short-circuiting. Now we use a combination of `map` and `fold`, which exhausts the `.children()` iterator properly.
1 parent 2b193ae commit 52172f0

File tree

1 file changed

+41
-3
lines changed

1 file changed

+41
-3
lines changed

server/bleep/src/agent/transcoder.rs

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ fn offset_embedded_link_ranges<'a>(element: &'a comrak::nodes::AstNode<'a>, offs
139139

140140
_ => element
141141
.children()
142-
.any(|child| offset_embedded_link_ranges(child, offset)),
142+
.map(|child| offset_embedded_link_ranges(child, offset))
143+
.fold(false, |a, e| a || e)
143144
}
144145
}
145146

@@ -1316,14 +1317,51 @@ func sendSlackMessage(org string) error {
13161317

13171318
#[test]
13181319
fn test_encode_indexing_base() {
1320+
// We test a list with *two* items to check that short circuiting logic doesn't case
1321+
// issues.
1322+
13191323
let input = "Foo [bar](bar.rs#L0-L9) quux.
13201324
1321-
- Fred [thud](thud.rs#L0-L9) corge.";
1325+
- Fred [thud](thud.rs#L0-L9) corge.
1326+
- Grault [garply](waldo.rs#L0-L9) plugh.";
13221327

13231328
let expected = "Foo [bar](bar.rs#L1-L10) quux.
13241329
1325-
- Fred [thud](thud.rs#L1-L10) corge.";
1330+
- Fred [thud](thud.rs#L1-L10) corge.
1331+
- Grault [garply](waldo.rs#L1-L10) plugh.";
13261332

13271333
assert_eq!(expected, encode(input, None));
13281334
}
1335+
1336+
#[test]
1337+
fn test_bug_short_circuit_link_offset() {
1338+
let input = "Yes, this project is deployable on Kubernetes. The project contains a Helm chart located in the [`helm/bloop/`](helm/bloop/) directory. This chart includes various Kubernetes resource definitions such as:
1339+
1340+
- A [`Deployment`](helm/bloop/templates/bloop-deployment.yaml#L1-L21) for the main application
1341+
- A [`Service`](helm/bloop/templates/bloop-service.yaml#L1-L18) to expose the application within the cluster
1342+
- A [`PersistentVolumeClaim`](helm/bloop/templates/bloop-pvc.yaml#L1-L15) for persistent storage
1343+
- A [`StatefulSet`](helm/bloop/templates/qdrant-statefulset.yaml#L1-L145) for the Qdrant service
1344+
- A [`Job`](helm/bloop/templates/notification-job.yaml#L1-L25) for sending notifications
1345+
1346+
The Helm chart's configurable values are defined in the [`values.yaml`](helm/bloop/values.yaml#L1-L201) file.
1347+
1348+
[^summary]: Yes, this project is deployable on Kubernetes. It includes a Helm chart with definitions for various Kubernetes resources such as Deployments, Services, PersistentVolumeClaims, StatefulSets, and Jobs.";
1349+
1350+
let expected_body = "Yes, this project is deployable on Kubernetes. The project contains a Helm chart located in the [`helm/bloop/`](helm/bloop/) directory. This chart includes various Kubernetes resource definitions such as:
1351+
1352+
- A [`Deployment`](helm/bloop/templates/bloop-deployment.yaml#L0-L20) for the main application
1353+
- A [`Service`](helm/bloop/templates/bloop-service.yaml#L0-L17) to expose the application within the cluster
1354+
- A [`PersistentVolumeClaim`](helm/bloop/templates/bloop-pvc.yaml#L0-L14) for persistent storage
1355+
- A [`StatefulSet`](helm/bloop/templates/qdrant-statefulset.yaml#L0-L144) for the Qdrant service
1356+
- A [`Job`](helm/bloop/templates/notification-job.yaml#L0-L24) for sending notifications
1357+
1358+
The Helm chart's configurable values are defined in the [`values.yaml`](helm/bloop/values.yaml#L0-L200) file.";
1359+
1360+
let expected_conclusion = "Yes, this project is deployable on Kubernetes. It includes a Helm chart with definitions for various Kubernetes resources such as Deployments, Services, PersistentVolumeClaims, StatefulSets, and Jobs.";
1361+
1362+
let (body, conclusion) = decode(input);
1363+
1364+
assert_eq!(expected_body, body);
1365+
assert_eq!(expected_conclusion, conclusion.unwrap());
1366+
}
13291367
}

0 commit comments

Comments
 (0)