{"record":{"id":"dabdfb6f28823665","repo":"grafana/k6","slug":"invalid-maxsendsize-value-v-it-needs-to-be-a-dabdfb","errorCode":null,"errorMessage":"invalid maxSendSize value: '%#v, it needs to be a positive integer","messagePattern":"invalid maxSendSize 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":200,"sourceCode":"\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 {\n\t\t\t\treturn result, fmt.Errorf(\"invalid authority value: '%#v', it needs to be a string\", v)\n\t\t\t}\n\t\tdefault:\n\t\t\treturn result, fmt.Errorf(\"unknown connect param: %q\", k)\n\t\t}\n\t}\n\n\treturn result, nil\n}","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/grpc/params.go#L182-L218","documentation":"After the integer check, newConnectParams rejects negative maxSendSize values (params.go:199): the send 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, { maxSendSize: -1 }) — a -1 'unlimited' or 'not set' convention leaking into the params object, or size arithmetic that underflowed.","commonSituations":"Configs using -1 as the 'unlimited' convention; computed limits (payload budget minus overhead) going negative for small budgets.","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, { maxSendSize: -1 });\n\n// after\nclient.connect(addr, { maxSendSize: 0 }); // 0 = no explicit limit","handlingStrategy":"validation","validationCode":"if (connectParams.maxSendSize !== undefined) {\n  const n = connectParams.maxSendSize;\n  if (typeof n !== 'number' || !Number.isInteger(n) || n < 0) {\n    throw new Error(`maxSendSize 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"}