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

[BUG] capability provider stuck at the Awaiting state #606

Closed
VanjaRo opened this issue Apr 10, 2023 · 1 comment · Fixed by #607
Closed

[BUG] capability provider stuck at the Awaiting state #606

VanjaRo opened this issue Apr 10, 2023 · 1 comment · Fixed by #607
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@VanjaRo
Copy link

VanjaRo commented Apr 10, 2023

Describe the bug

After adding a custom capability provider through the Dashboard UI, I noticed that the newly added provider remains in the Awaiting state.
When trying to access the always-waiting provider through an actor call -- I receive the following error

ERROR wasmbus_rpc::rpc_client] rpc error response error=Guest call failed for method HttpServer.HandleRequest: Host send error Host call function failed: [73, 110, 118, 111, 99, 97, 116, 105, 111, 110, 32, 110, 111, 116, 32, 97, 117, 116, 104, 111, 114, 105, 122, 101, 100, 58, 32, 109, 105, 115, 115, 105, 110, 103, 32, 108, 105, 110, 107, 32, 100, 101, 102, 105, 110, 105, 116, 105, 111, 110, 32, 102, 111, 114, 32, 119, 97, 115, 109, 99, 108, 111, 117, 100, 58, 101, 120, 97, 109, 112, 108, 101, 115, 58, 104, 97, 115, 104, 101, 115, 32, 111, 110, 32, 100, 101, 102, 97, 117, 108, 116]

Actor call without provider interaction works successfully.
Btw, tried to decode given array of integers with msgpack, received: "73". Very helpful 👍

Provider interface:

...
@wasmbus(
    contractId: "wasmcloud:examples:hashes",
    actorReceive: true,
    providerReceive: true )
service Hashes {
  version: "0.1",
  operations: [ Calculate ]
}

/// Calculates the hash of given password
operation Calculate {
  input: GenerateHashRequest,
  output: GenerateHashResponse,
}

/// Parameters sent for GenerateHash
structure GenerateHashRequest {
    /// Name of hash function to generate hash
    @required
    hashMethod: String,

    /// The password string that will be hashed
    @required
    passwordString: String,
}

/// Response to GenerateHash
structure GenerateHashResponse {
    /// Indicates a successful generating
    @required
    success: Boolean,

    /// String with password hash
    passwordHash: String,

    /// Optional string with fail reason
    failReason: String,
}

Actor to provider call:
hash_type and msg variables are strings

...
        let hash_request = GenerateHashRequest {
            hash_method: hash_type,
            password_string: msg,
        };

        let provider = HashesSender::new();
        let hash_response = provider.calculate(ctx, &hash_request).await?;
...

Provider core logic:

fn main() -> Result<(), Box<dyn std::error::Error>> {
    provider_main(HashesProviderProvider::default(), Some("HashesProvider".to_string()))?;

    eprintln!("hashes-provider provider exiting");
    Ok(())
}

#[derive(Default, Clone, Provider)]
#[services(Hashes)]
struct HashesProviderProvider {}

impl ProviderDispatch for HashesProviderProvider {}
impl ProviderHandler for HashesProviderProvider {}

#[async_trait]
impl Hashes for HashesProviderProvider {
    /// accepts a password and generate its hash
    async fn calculate(&self, _ctx: &Context, _arg: &GenerateHashRequest) -> RpcResult<GenerateHashResponse> {
        debug!("generating hash for string {}", _arg.password_string.clone());
        Ok(gen_hash(_arg))
    }
}

I've also noticed that when I try to remove the provider through the dashboard UI, I get a log message telling me that the process doesn't exist:

process2023-04-10T13:07:15.182753Z  INFO wasmbus_rpc::provider: Received termination signal and stopping
hashes-provider provider exiting
kill: (2240924): No such process

Environment
Was running wasmcloud_host locally.

  • OS: Linux
  • Arch: x86_64
  • wasmCloud Version: 0.62.0
@VanjaRo VanjaRo added bug Something isn't working help wanted Extra attention is needed labels Apr 10, 2023
@connorsmith256
Copy link
Contributor

Thanks for the report @VanjaRo. We'll look into how the host is reporting errors; that byte array should be deserialized as a string. It's not messagepack-encoded, by the way, just plain text. I decoded it for you in my browser:

[73, 110, 118, 111, 99, 97, 116, 105, 111, 110, 32, 110, 111, 116, 32, 97, 117, 116, 104, 111, 114, 105, 122, 101, 100, 58, 32, 109, 105, 115, 115, 105, 110, 103, 32, 108, 105, 110, 107, 32, 100, 101, 102, 105, 110, 105, 116, 105, 111, 110, 32, 102, 111, 114, 32, 119, 97, 115, 109, 99, 108, 111, 117, 100, 58, 101, 120, 97, 109, 112, 108, 101, 115, 58, 104, 97, 115, 104, 101, 115, 32, 111, 110, 32, 100, 101, 102, 97, 117, 108, 116]
  .map(c => String.fromCharCode(c)).join('')
'Invocation not authorized: missing link definition for wasmcloud:examples:hashes on default'

So for your specific error, this means the host didn't detect a link between your actor and provider for the contract wasmcloud:examples:hashes with the name default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants