bynk.context.external_decode
Error A context decoded a type another context owns and exports opaque: through Json.decode, Json.decodeSql or a Codable witness, or as the input of an HTTP, queue, event or WebSocket handler. Decoding creates a value, which only the owning context may do; its codec would check no more than the base type.
Decoding creates a value, and a context may not create one of a type another context owns and exports opaque. A decoder would check no more than the base type, because the owner's predicate is the owner's secret. So a handler that takes such a type as its input (an HTTP, queue, event or WebSocket handler decodes it from bytes), and a Json.decode, Json.decodeSql or Codable witness of it, are refused. Take the plain form of the input and let the owner's service make the value. A reply from the owner's own service is fine: its decode is generated.
Example
context pay
exports opaque { Token }
type Token = opaque String where Matches("T-[0-9]+")
// shop.bynkcontext shop
consumes pay
service api from http { on POST("/t") (body: Token) -> Effect[HttpResult[String]] by v: Visitor { // ✗ `Token` cannot be decoded here on POST("/t") (body: String) -> Effect[HttpResult[String]] by v: Visitor { // ✓ take the plain inputIn the Book
See also
- Every code in its category, Contexts, on the diagnostic index.
bynk explain bynk.context.external_decodeshows the same from the installed toolchain, without a network.