{"record":{"id":"1c5eb9cbb7eb60ad","repo":"grafana/k6","slug":"invalid-maxreceivesize-value-v-it-needs-to-be","errorCode":null,"errorMessage":"invalid maxReceiveSize value: '%#v, it needs to be a positive integer","messagePattern":"invalid maxReceiveSize value: '%#v, it needs to be a positive integer","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/grpc/params.go","lineNumber":191,"sourceCode":"\t\t\tresult.UseReflectionProtocol, ok = v.(bool)\n\t\t\tif !ok {\n\t\t\t\treturn result, fmt.Errorf(\"invalid reflect value: '%#v', it needs to be boolean\", v)\n\t\t\t}\n\t\tcase \"reflectMetadata\":\n\t\t\tmd, err := newMetadata(params.Get(k))\n\t\t\tif err != nil {\n\t\t\t\treturn result, fmt.Errorf(\"invalid reflectMetadata param: %w\", err)\n\t\t\t}\n\n\t\t\tresult.ReflectionMetadata = md\n\t\tcase \"maxReceiveSize\":\n\t\t\tvar ok bool\n\t\t\tresult.MaxReceiveSize, ok = v.(int64)\n\t\t\tif !ok {\n\t\t\t\treturn result, fmt.Errorf(\"invalid maxReceiveSize value: '%#v', it needs to be an integer\", v)\n\t\t\t}\n\t\t\tif result.MaxReceiveSize < 0 {\n\t\t\t\treturn result, fmt.Errorf(\"invalid maxReceiveSize value: '%#v, it needs to be a positive integer\", v)\n\t\t\t}\n\t\tcase \"maxSendSize\":\n\t\t\tvar ok bool\n\t\t\tresult.MaxSendSize, ok = v.(int64)\n\t\t\tif !ok {\n\t\t\t\treturn result, fmt.Errorf(\"invalid maxSendSize value: '%#v', it needs to be an integer\", v)\n\t\t\t}\n\t\t\tif result.MaxSendSize < 0 {\n\t\t\t\treturn result, fmt.Errorf(\"invalid maxSendSize value: '%#v, it needs to be a positive integer\", v)\n\t\t\t}\n\t\tcase \"tls\":\n\t\t\tif err := parseConnectTLSParam(result, v); err != nil {\n\t\t\t\treturn result, err\n\t\t\t}\n\t\tcase \"authority\":\n\t\t\tvar ok bool\n\t\t\tresult.Authority, ok = v.(string)\n\t\t\tif !ok {","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/grpc/params.go#L173-L209","documentation":"After the integer check, newConnectParams rejects negative maxReceiveSize values (params.go:190): the receive limit cannot be negative, and 0 means no limit. (The error text also has a cosmetic missing closing quote after the value.)","triggerScenarios":"connect(addr, { maxReceiveSize: -1 }) — typically an attempt to mean 'unlimited', or a -1 'not set' sentinel leaking from config/code into the params object.","commonSituations":"Configs using -1 as the 'unlimited' convention; arithmetic that computes a size by subtraction and underflows to a negative number.","solutions":["Use 0 for no explicit limit","Clamp sentinel -1 values to 0 before calling connect","Re-check the computation that produced the negative number"],"exampleFix":"// before\nclient.connect(addr, { maxReceiveSize: -1 }); // -1 is not 'unlimited'\n\n// after\nclient.connect(addr, { maxReceiveSize: 0 }); // 0 = no explicit limit","handlingStrategy":"validation","validationCode":"if (connectParams.maxReceiveSize !== undefined) {\n  const n = connectParams.maxReceiveSize;\n  if (typeof n !== 'number' || !Number.isInteger(n) || n < 0) {\n    throw new Error(`maxReceiveSize must be a non-negative integer, got ${n} (use 0 for no limit)`);\n  }\n}\nclient.connect(addr, connectParams);","typeGuard":"function isByteSize(v) {\n  return typeof v === 'number' && Number.isInteger(v) && v >= 0;\n}","tryCatchPattern":null,"preventionTips":["Use 0, not -1, to mean 'no explicit limit'","Map config -1 sentinels to 0 in the config loader","Guard computed sizes with Math.max(0, n)"],"tags":["grpc","connect","size-limits","validation"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}