Skip to content

Commit

Permalink
fix: fixed duplicate pluck ids causing Too many connections to input …
Browse files Browse the repository at this point in the history
…port 'input' errors
  • Loading branch information
jsoverson committed Jul 7, 2023
1 parent 275acaa commit 41f05ac
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 5 deletions.
4 changes: 2 additions & 2 deletions crates/wick/flow-graph-interpreter/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,13 @@ fn expand_port_paths(
schematic: &mut Schematic,
expressions: &mut [FlowExpression],
) -> Result<(), flow_graph::error::Error> {
for expression in expressions.iter_mut() {
for (i, expression) in expressions.iter_mut().enumerate() {
if let FlowExpression::ConnectionExpression(expr) = expression {
let (from, to) = expr.clone().into_parts();
let (from_inst, from_port, _) = from.into_parts();
let (to_inst, to_port, _) = to.into_parts();
if let InstancePort::Path(name, parts) = from_port {
let id = format!("{}_pluck_{}_[{}]", schematic.name(), name, parts.join(","));
let id = format!("{}_pluck_{}_{}_[{}]", schematic.name(), i, name, parts.join(","));
let config = HashMap::from([(
"path".to_owned(),
Value::Array(parts.into_iter().map(Value::String).collect()),
Expand Down
29 changes: 29 additions & 0 deletions crates/wick/flow-graph-interpreter/tests/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,35 @@ async fn test_pluck() -> Result<()> {
.await
}

#[test_logger::test(tokio::test)]
async fn test_pluck_substreams() -> Result<()> {
test_config(
"./tests/manifests/v1/core-pluck-streams.yaml",
None,
None,
vec![
Packet::open_bracket("input"),
Packet::encode("input", json!({"value": "value1!"})),
Packet::encode("input", json!({"value": "value2!"})),
Packet::close_bracket("input"),
Packet::done("input"),
],
vec![
Packet::open_bracket("pluck1"),
Packet::encode("pluck1", "value1!"),
Packet::encode("pluck1", "value2!"),
Packet::close_bracket("pluck1"),
Packet::done("pluck1"),
Packet::open_bracket("pluck2"),
Packet::encode("pluck2", "value1!"),
Packet::encode("pluck2", "value2!"),
Packet::close_bracket("pluck2"),
Packet::done("pluck2"),
],
)
.await
}

#[test_logger::test(tokio::test)]
async fn test_pluck_shorthand() -> Result<()> {
first_packet_test(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,3 @@ component:
- name: test
flow:
- <>.request.headers.cookie.0 -> <>.output
- name: test2
flow:
- '<>.input."Raw String Field #" -> <>.output'
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
name: 'test'
kind: wick/component@v1
metadata:
version: '0.0.2'
component:
kind: wick/component/composite@v1
operations:
- name: test
flow:
- <>.input.value -> <>.pluck1
- <>.input.value -> <>.pluck2

0 comments on commit 41f05ac

Please sign in to comment.