{"record":{"id":"42caec66231f0f8b","repo":"vitessio/vitess","slug":"cannot-parse-vtportstart-v","errorCode":null,"errorMessage":"cannot parse VTPORTSTART: %v","messagePattern":"cannot parse VTPORTSTART: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/testfiles/ports.go","lineNumber":83,"sourceCode":"\tGoVtVtctlWorkflowPort     = vtPortStart + 15 // etcd client URL\n\tGoVtVtctlWorkflowPeerPort = vtPortStart + 16 // etcd peer URL\n)\n\n// Zookeeper server ID definitions. Unit tests may run at the\n// same time, so they can't use the same Zookeeper server IDs.\nvar (\n\t// GoVtTopoZk2topoZkID is used by the go/vt/topo/zk2topo package.\n\tGoVtTopoZk2topoZkID = 1\n)\n\nfunc getPortStart() int {\n\tenv := os.Getenv(\"VTPORTSTART\")\n\tif env == \"\" {\n\t\tenv = \"6700\"\n\t}\n\tportStart, err := strconv.Atoi(env)\n\tif err != nil {\n\t\tpanic(fmt.Errorf(\"cannot parse VTPORTSTART: %v\", err))\n\t}\n\treturn portStart\n}\n","sourceCodeStart":65,"sourceCodeEnd":87,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/testfiles/ports.go#L65-L87","documentation":"getPortStart in go/testfiles/ports.go reads the VTPORTSTART environment variable and panics if it is not an integer. This is test-infrastructure code: it fails fast at test setup when the port-range override is malformed, since test ports cannot be allocated reliably without it.","triggerScenarios":"Setting VTPORTSTART to a non-numeric value (e.g. \"67a0\", \"\" handled by default, but \"6700 \" with whitespace or \"67,00\" fails) before running Vitess tests.","commonSituations":"CI environment variable set with stray characters or quotes; local wrapper scripts exporting VTPORTSTART with a suffix; copy-paste including units like \"6700/tcp\".","solutions":["Unset VTPORTSTART to use the default 6700, or set it to a plain integer (e.g. export VTPORTSTART=6700)","Strip whitespace/quotes/units from the variable in your test wrapper script","Check CI config files for the variable definition and correct the value"],"exampleFix":"// before\nexport VTPORTSTART=\"6700/tcp\"\n// after\nexport VTPORTSTART=6700","handlingStrategy":"validation","validationCode":"if v := os.Getenv(\"VTPORTSTART\"); v != \"\" {\n\tif _, err := strconv.Atoi(v); err != nil {\n\t\treturn fmt.Errorf(\"VTPORTSTART must be an integer, got %q\", v)\n\t}\n}","typeGuard":null,"tryCatchPattern":"func mustPortStart() int {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tlog.Error(\"bad VTPORTSTART; defaulting\", slog.Any(\"panic\", r))\n\t\t}\n\t}()\n\treturn vtPortStart()\n}","preventionTips":["Export VTPORTSTART as a bare integer without quotes/units in CI scripts","Unset the variable entirely to use the default 6700","Add an env lint step that validates test env vars before running tests"],"tags":["go","testing","environment-variable","ports"],"backgroundTag":"invalid-env-var-value","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}