opa icon indicating copy to clipboard operation
opa copied to clipboard

Running `inspect` on a WASM bundle fails if the bundle contains an annotation with the `related_resources` metadata field

Open dxh9845 opened this issue 8 months ago • 4 comments

Short description

Running opa inspect on a built WASM bundle that has the following related_resources annotation:

package main

import data.meta.foo

# METADATA
# entrypoint: true
# related_resources:
#  - ref: https://google.com
#    description: Some description
zone_alias := foo

Will fail with the following message:

error: bundle bundle.tar.gz: bundle load failed on manifest decode: json: cannot unmarshal string into Go struct field RelatedResourceAnnotation.wasm.annotations.related_resources.ref of type url.URL

Steps To Reproduce

  1. Clone the following repo: https://github.com/dxh9845/opa-broken-wasm-build-poc/tree/dherzig/broken-annotations
git clone https://github.com/dxh9845/opa-broken-wasm-build-poc.git
  1. Checkout the branch containing the broken behavior:
git checkout dherzig/broken-annotations
  1. Run make fail to build the bundle and see the failure:
make fail

Expected behavior

OPA can inspect the built WASM bundle without an error.

Additional context

This works for OPA packages built for rego. However, the WASM implementation seemingly cannot handle

dxh9845 avatar May 29 '24 17:05 dxh9845