{"record":{"id":"2f073cfd4081d0de","repo":"grafana/k6","slug":"s-failed-w","errorCode":null,"errorMessage":"%s failed: %w","messagePattern":"(.+?) failed: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/crypto/crypto.go","lineNumber":149,"sourceCode":"func (c *Crypto) ripemd160(input any, outputEncoding string) (any, error) {\n\treturn c.buildInputsDigest(\"ripemd160\", input, outputEncoding)\n}\n\n// createHash returns a Hasher instance that uses the given algorithm.\nfunc (c *Crypto) createHash(algorithm string) *Hasher {\n\thashfn := c.parseHashFunc(algorithm)\n\treturn &Hasher{\n\t\truntime: c.vu.Runtime(),\n\t\thash:    hashfn(),\n\t}\n}\n\n// buildInputsDigest implements basic digest calculation for given algorithm and input/output\nfunc (c *Crypto) buildInputsDigest(alg string, input any, outputEncoding string) (any, error) {\n\thasher := c.createHash(alg)\n\n\tif err := hasher.Update(input); err != nil {\n\t\treturn nil, fmt.Errorf(\"%s failed: %w\", alg, err)\n\t}\n\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)","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/crypto/crypto.go#L131-L167","documentation":"A generic wrap ('%s' is the algorithm name, e.g. md5/sha256) raised inside the crypto module's buildInputsDigest pipeline — it catches failures while preparing the hasher inputs (converting the input value to bytes via common.ToBytes). It fires when the JS-provided input cannot be converted to a byte buffer (unsupported type), before any hashing occurs; the algorithm name merely labels the entry point (md4/md5/sha1/sha256/sha384/sha512) that was invoked.","triggerScenarios":"Thrown at internal/js/modules/k6/crypto/crypto.go:149 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a string, ArrayBuffer, or TypedArray as the input to the hash function","Convert custom objects to a string/bytes before hashing","Check the wrapped error for the exact input conversion failure","Verify the output encoding argument is one of the supported values"],"exampleFix":null,"handlingStrategy":"type-guard","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-14T05:17:10.506Z"}