Skip to content

wac not recognizing import #167

@Back0fnGurke

Description

@Back0fnGurke

wac version 0.7.0

Using wac compose results in an error stating that the core component does not define an import which it clearely does according to wasm-tools. The component providing said import exports the needed interface. Using wac plug works as intended.

WIT definition of the core component

package prototype:core@0.1.0;

interface converter{
  enum error-code {
    conversion-failed,
  }

  record error-detail {
    code: error-code,
    message: string,
  }

  convert: func(input: list<u8>, trace-id: string) -> result<list<u8>, error-detail>;
}

interface handler-outgoing {
  enum error-code {
    fetching-product-list-failed,
  }

  record error-detail {
    code: error-code,
    message: string,
  }

  get-product-list: func(id: string, trace-id: string) -> result<list<u8>, error-detail>;
}

interface core-logic {
  enum error-code {
    failed-to-get-product-list,
    failed-to-convert-product-list,
  }

  record error-detail {
    code: error-code,
    message: string,
  }

  get-product-list-csv: func(id: string, trace-id: string) -> result<list<u8>, error-detail>;
}

world core {
  import wasi:cli/environment@0.2.0;
  import wasi:cli/stdout@0.2.0;
  import wasi:cli/stderr@0.2.0;
  import wasi:cli/stdin@0.2.0;
  import wasi:clocks/wall-clock@0.2.0;
  import wasi:clocks/monotonic-clock@0.2.0;
  import wasi:random/random@0.2.0;
  import wasi:filesystem/types@0.2.0;
  import wasi:filesystem/preopens@0.2.0;
  import wasi:io/streams@0.2.0;

  import converter;
  import handler-outgoing;

  export core-logic;
}

WIT definition retrieved from core component with wasm-tools

world root {
  import wasi:cli/environment@0.2.0;
  import wasi:io/error@0.2.0;
  import wasi:io/streams@0.2.0;
  import wasi:cli/stdout@0.2.0;
  import wasi:cli/stderr@0.2.0;
  import wasi:cli/stdin@0.2.0;
  import wasi:clocks/wall-clock@0.2.0;
  import wasi:clocks/monotonic-clock@0.2.0;
  import wasi:random/random@0.2.0;
  import wasi:filesystem/types@0.2.0;
  import wasi:filesystem/preopens@0.2.0;
  **import prototype:core/converter@0.1.0;**
  import prototype:core/handler-outgoing@0.1.0;

  export prototype:core/core-logic@0.1.0;
}

WIT definition retrieved from xml-converter component with wasm-tools

world root {
  import wasi:cli/environment@0.2.0;
  import wasi:cli/exit@0.2.0;
  import wasi:io/error@0.2.0;
  import wasi:io/poll@0.2.0;
  import wasi:io/streams@0.2.0;
  import wasi:cli/stdin@0.2.0;
  import wasi:cli/stdout@0.2.0;
  import wasi:cli/stderr@0.2.0;
  import wasi:cli/terminal-input@0.2.0;
  import wasi:cli/terminal-output@0.2.0;
  import wasi:cli/terminal-stdin@0.2.0;
  import wasi:cli/terminal-stdout@0.2.0;
  import wasi:cli/terminal-stderr@0.2.0;
  import wasi:clocks/monotonic-clock@0.2.0;
  import wasi:clocks/wall-clock@0.2.0;
  import wasi:filesystem/types@0.2.0;
  import wasi:filesystem/preopens@0.2.0;
  import wasi:sockets/network@0.2.0;
  import wasi:sockets/instance-network@0.2.0;
  import wasi:sockets/udp@0.2.0;
  import wasi:sockets/udp-create-socket@0.2.0;
  import wasi:sockets/tcp@0.2.0;
  import wasi:sockets/tcp-create-socket@0.2.0;
  import wasi:sockets/ip-name-lookup@0.2.0;
  import wasi:random/random@0.2.0;
  import wasi:random/insecure@0.2.0;
  import wasi:random/insecure-seed@0.2.0;

  export exports: interface {
    record bundled {
      module: string,
      protocol: string,
      name: string,
    }

    record function {
      protocol: string,
      name: string,
    }

    record %constructor {
      module: string,
      protocol: string,
    }

    record %static {
      module: string,
      protocol: string,
      name: string,
    }

    variant function-export {
      bundled(bundled),
      freestanding(function),
      %constructor(%constructor),
      method(string),
      %static(%static),
    }

    record case {
      name: string,
      has-payload: bool,
    }

    record local-resource {
      new: u32,
      rep: u32,
      drop: u32,
    }

    record remote-resource {
      drop: u32,
    }

    record %resource {
      local: option<local-resource>,
      remote: option<remote-resource>,
    }

    variant owned-kind {
      %record(list<string>),
      %variant(list<case>),
      %enum(u32),
      %flags(u32),
      %resource(%resource),
    }

    record owned-type {
      kind: owned-kind,
      %package: string,
      name: string,
    }

    variant %type {
      owned(owned-type),
      %option,
      nesting-option,
      %result,
      %tuple(u32),
      handle,
    }

    record symbols {
      types-package: string,
      exports: list<function-export>,
      types: list<%type>,
    }

    init: func(app-name: string, symbols: symbols, stub-wasi: bool) -> result<_, string>;
  }
  **export prototype:core/converter@0.1.0;**
}

WAC definition

package prototype:app@0.1.0;

let network-outgoing = new prototype:network-outgoing {...};
let xml-converter = new prototype:xml-converter {...};

let core = new prototype:core {
    converter: xml-converter.converter,
    handler-outgoing: network-outgoing.handler-outgoing,
    ...
};

let network-incoming = new prototype:network-incoming {
    core-logic: core.core-logic,
    ...
};

export network-incoming.incoming-handler;

Error using wac compose

error: failed to resolve document

  × component `prototype:core` has no import named `converter`
   ╭─[app.wac:7:5]
 6 │ let core = new prototype:core {
 7 │     converter: xml-converter.converter,
   ·     ────┬────
   ·         ╰── unknown import `converter`
 8 │     handler-outgoing: network-outgoing.handler-outgoing,
   ╰────

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions