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

fix: allow namespaces with slashes #631

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/actor/src/compat/wasmcloud/bus/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ pub fn call_sync(
match target {
None => {
let (namespace, operation) = operation
.split_once('/')
.rsplit_once('/')
.ok_or_else(|| "invalid operation format".to_string())?;
host_call("", namespace, operation, payload)
}
Some(TargetEntity::Link(binding)) => {
let (namespace, operation) = operation
.split_once('/')
.rsplit_once('/')
.ok_or_else(|| "invalid operation format".to_string())?;
host_call(
binding.as_deref().unwrap_or_default(),
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl Invocation {
) -> anyhow::Result<Invocation> {
let operation = operation.into();
let (_, operation) = operation
.split_once('/')
.rsplit_once('/')
.context("failed to parse operation")?;
// TODO: Support per-interface links
let id = Uuid::from_u128(Ulid::new().into()).to_string();
Expand Down
4 changes: 2 additions & 2 deletions crates/host/src/wasmbus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ impl Handler {
let aliases = self.aliases.read().await;
let operation = operation.into();
let (package, _) = operation
.split_once('/')
.rsplit_once('/')
.context("failed to parse operation")?;
let inv_target = resolve_target(target, links.get(package), &aliases).await?;
let needs_chunking = request.len() > CHUNK_THRESHOLD_BYTES;
Expand Down Expand Up @@ -722,7 +722,7 @@ impl Bus for Handler {
let links = links.read().await;
let aliases = aliases.read().await;
let (package, _) = operation
.split_once('/')
.rsplit_once('/')
.context("failed to parse operation")
.map_err(|e| e.to_string())?;
let inv_target = resolve_target(target.as_ref(), links.get(package), &aliases)
Expand Down
10 changes: 5 additions & 5 deletions crates/runtime/tests/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ impl capability::Bus for Handler {
("", "foobar-component-command-preview2") => Ok(capability::TargetEntity::Actor(
capability::ActorIdentifier::Alias("foobar-component-command-preview2".into()),
)),
("", "unknown") => Ok(capability::TargetEntity::Actor(
capability::ActorIdentifier::Alias("unknown".into()),
("", "unknown/alias") => Ok(capability::TargetEntity::Actor(
capability::ActorIdentifier::Alias("unknown/alias".into()),
)),
_ => panic!("binding `{binding}` namespace `{namespace}` pair not supported"),
}
Expand Down Expand Up @@ -313,10 +313,10 @@ impl capability::Bus for Handler {
Some(capability::TargetEntity::Actor(capability::ActorIdentifier::Alias(name))),
"test-actors:foobar/actor.foobar" // component invocation
| "foobar-component-command-preview2/actor.foobar" // valid module invocation
| "unknown/actor.foobar", // invalid module invocation
) if name == "foobar-component-command-preview2" || name == "unknown" => {
| "unknown/alias/actor.foobar", // invalid module invocation
) if name == "foobar-component-command-preview2" || name == "unknown/alias" => {
assert_eq!(payload, br#"{"arg":"foo"}"#);
if name == "unknown" {
if name == "unknown/alias" {
bail!("unknown actor call alias")
} else {
Ok(r#""foobar""#.into())
Expand Down
2 changes: 1 addition & 1 deletion tests/actors/rust/builtins-compat-reactor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ impl exports::wasmcloud::bus::guest::Guest for Actor {

bus::host::call_sync(
Some(&TargetEntity::Actor(bus::lattice::ActorIdentifier::Alias(
"unknown".into(),
"unknown/alias".into(),
))),
"test-actors:foobar/actor.foobar",
r#"{"arg":"foo"}"#.as_bytes(),
Expand Down
2 changes: 1 addition & 1 deletion tests/actors/rust/builtins-component-reactor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ impl exports::wasi::http::incoming_handler::Guest for Actor {

bus::host::call_sync(
Some(&TargetEntity::Actor(bus::lattice::ActorIdentifier::Alias(
"unknown".into(),
"unknown/alias".into(),
))),
"test-actors:foobar/actor.foobar",
r#"{"arg":"foo"}"#.as_bytes(),
Expand Down
2 changes: 1 addition & 1 deletion tests/actors/rust/builtins-module-reactor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ impl HttpHandler for HttpLogRng {

bus::host::call_sync(
Some(&TargetEntity::Actor(bus::lattice::ActorIdentifier::Alias(
"unknown".into(),
"unknown/alias".into(),
))),
// TODO: This should include the package name, i.e. `test-actors:foobar/actor.foobar`
"actor.foobar",
Expand Down