Skip to content
Playground(another site)

bynk.actor.bearer_identity_not_string_constructible

Error A Bearer actor's identity is not a string-constructible type.

A Bearer actor's identity is minted from the token's sub claim, which is a string, so the identity type must be one a string can become: a refined or opaque String. Any other type has no way to be built from the claim, and an actor with no identity at all is refused for the same reason. Declare a type over String, such as type UserId = String where NonEmpty, and name it as the identity. An Oidc actor has the same rule under bynk.actor.oidc_identity_not_string_constructible.

Example

type Age = Int where NonNegative
actor User { auth = Bearer(secret = "JWT_KEY"), identity = Age } // ✗ a token's `sub` is a string, not an `Int`
type UserId = String where NonEmpty
actor User { auth = Bearer(secret = "JWT_KEY"), identity = UserId } // ✓ minted from `sub`

In the Book

See also

  • Every code in its category, Actors, on the diagnostic index.
  • bynk explain bynk.actor.bearer_identity_not_string_constructible shows the same from the installed toolchain, without a network.