{"record":{"id":"ff338f3fab93f2cb","repo":"grafana/k6","slug":"failed-to-decode-modulus-w","errorCode":null,"errorMessage":"failed to decode modulus: %w","messagePattern":"failed to decode modulus: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/webcrypto/jwk.go","lineNumber":338,"sourceCode":"\n\t// TODO: consider validating the other fields in future\n\treturn nil\n}\n\nfunc importRSAJWK(jsonKeyData []byte) (any, CryptoKeyType, int, error) {\n\tvar jwk rsaJWK\n\tif err := json.Unmarshal(jsonKeyData, &jwk); err != nil {\n\t\treturn nil, UnknownCryptoKeyType, 0, fmt.Errorf(\"failed to parse input as RSA JWK key: %w\", err)\n\t}\n\n\tif err := jwk.validate(); err != nil {\n\t\treturn nil, UnknownCryptoKeyType, 0, fmt.Errorf(\"invalid RSA JWK key: %w\", err)\n\t}\n\n\t// decode the various key components\n\tnBytes, err := base64URLDecode(jwk.N)\n\tif err != nil {\n\t\treturn nil, UnknownCryptoKeyType, 0, fmt.Errorf(\"failed to decode modulus: %w\", err)\n\t}\n\teBytes, err := base64URLDecode(jwk.E)\n\tif err != nil {\n\t\treturn nil, UnknownCryptoKeyType, 0, fmt.Errorf(\"failed to decode exponent: %w\", err)\n\t}\n\n\t// convert exponent to an integer\n\teInt := new(big.Int).SetBytes(eBytes).Int64()\n\tpubKey := rsa.PublicKey{\n\t\tN: new(big.Int).SetBytes(nBytes),\n\t\tE: int(eInt),\n\t}\n\n\t// if the private exponent is missing, return the public key\n\tif jwk.D == \"\" {\n\t\treturn pubKey, PublicCryptoKeyType, pubKey.N.BitLen(), nil\n\t}\n","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/webcrypto/jwk.go#L320-L356","documentation":"Returned by importRSAJWK when the JWK's `n` field (the RSA modulus) fails base64url decoding. Structure and required-field validation passed, but the modulus string contains characters outside the base64url alphabet or has an invalid length, so the key size and public key cannot be constructed.","triggerScenarios":"Thrown at internal/js/modules/k6/webcrypto/jwk.go:337 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Encode n as unpadded base64url of the big-endian modulus bytes (256/384/512 bytes for RSA-2048/3072/4096)","Avoid plain base64 with '+' and '/' characters — convert to the URL-safe alphabet"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8d06114777191d21ef885d05c5f8aa9e1ed838ae","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}