{"record":{"id":"8816b9868b4e16fd","repo":"grafana/k6","slug":"invalid-algorithm-s","errorCode":null,"errorMessage":"invalid algorithm: %s","messagePattern":"invalid algorithm: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/crypto/crypto.go","lineNumber":169,"sourceCode":"\n\treturn hasher.Digest(outputEncoding)\n}\n\n// hexEncode returns a string with the hex representation of the provided byte\n// array or ArrayBuffer.\nfunc (c *Crypto) hexEncode(data any) (string, error) {\n\td, err := common.ToBytes(data)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn hex.EncodeToString(d), nil\n}\n\n// createHMAC returns a new HMAC hash using the given algorithm and key.\nfunc (c *Crypto) createHMAC(algorithm string, key any) (*Hasher, error) {\n\th := c.parseHashFunc(algorithm)\n\tif h == nil {\n\t\treturn nil, fmt.Errorf(\"invalid algorithm: %s\", algorithm)\n\t}\n\n\tkb, err := common.ToBytes(key)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Hasher{runtime: c.vu.Runtime(), hash: hmac.New(h, kb)}, nil\n}\n\n// HMAC returns a new HMAC hash of input using the given algorithm and key\n// in the given encoding.\nfunc (c *Crypto) hmac(algorithm string, key, input any, outputEncoding string) (any, error) {\n\thasher, err := c.createHMAC(algorithm, key)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = hasher.Update(input)\n\tif err != nil {","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/crypto/crypto.go#L151-L187","documentation":"Returned by createHMAC when parseHashFunc returns nil for the requested algorithm — a sentinel-style guard where '%s' names the unsupported algorithm string. It fires before any HMAC work begins, when the algorithm passed to crypto.hmac() is not one of the supported digest names (e.g. a typo like 'sha-256' instead of 'sha256', or an unsupported algorithm like 'ripemd160' which is digest-only).","triggerScenarios":"Thrown at internal/js/modules/k6/crypto/crypto.go:169 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a supported algorithm: md4, md5, sha1, sha256, sha384, or sha512","Check for typos and hyphenated names (sha-256 is invalid; use sha256)","Note ripemd160 is available for digests but not for HMAC in this module"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}