grafana/k6 · error

not a CryptoKey

Error message

not a CryptoKey

What it means

Error "not a CryptoKey" thrown in grafana/k6.

Source

Thrown at internal/js/modules/k6/webcrypto/key.go:50

	// PublicKey holds the public key. For encryption and decryption algorithms,
	// this key is used to encrypt. For signing and verification algorithms it is used to verify.
	PublicKey *CryptoKey `js:"publicKey"`
}

// IsKeyPair .
func (ckp *CryptoKeyPair) IsKeyPair() bool {
	return true
}

// ResolveCryptoKeyPair returns the underlying CryptoKeyPair.
func (ckp *CryptoKeyPair) ResolveCryptoKeyPair() (*CryptoKeyPair, error) {
	return ckp, nil
}

// ResolveCryptoKey returns an error since the underlying type is not a CryptoKey.
func (ckp *CryptoKeyPair) ResolveCryptoKey() (*CryptoKey, error) {
	return nil, errors.New("not a CryptoKey")
}

var _ CryptoKeyGenerationResult = &CryptoKeyPair{}

// CryptoKey represents a cryptographic key obtained from one of the SubtleCrypto
// methods `SubtleCrypto.generateKey`, `SubtleCrypto.DeriveKey`, `SubtleCrypto.ImportKey`,
// or `SubtleCrypto.UnwrapKey`.
type CryptoKey struct {
	// Type holds the type of the key.
	Type CryptoKeyType `js:"type"`

	// Extractable indicates whether or not the key may be extracted
	// using `SubtleCrypto.ExportKey` or `SubtleCrypto.WrapKey`.
	//
	// If the value is `true`, the key may be extracted.
	// If the value is `false`, the key may not be extracted, and
	// `SubtleCrypto.exportKey` and `SubtleCrypto.wrapKey` will fail.
	Extractable bool `js:"extractable"`

View on GitHub (pinned to 93accf6570)

When it happens

Trigger: Thrown at internal/js/modules/k6/webcrypto/key.go:50 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15). Data as JSON: /api/errors/9a3376946a195404. Report an issue: GitHub.