Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed "Too many connections to input port 'input'" errors for pluck path syntax #357

Merged
merged 1 commit into from
Jul 7, 2023
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
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