{"record":{"id":"1c7c9441b41d4d25","repo":"temporalio/temporal","slug":"error-getting-env-v","errorCode":null,"errorMessage":"error getting env %v","messagePattern":"error getting env (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"temporal/environment/env.go","lineNumber":87,"sourceCode":"// GetCassandraAddress return the cassandra address\nfunc GetCassandraAddress() string {\n\taddr := os.Getenv(cassandraSeedsEnv)\n\tif addr == \"\" {\n\t\taddr = GetLocalhostIP()\n\t}\n\treturn addr\n}\n\n// GetCassandraPort return the cassandra port\nfunc GetCassandraPort() int {\n\tport := os.Getenv(cassandraPortEnv)\n\tif port == \"\" {\n\t\treturn cassandraDefaultPort\n\t}\n\tp, err := strconv.Atoi(port)\n\tif err != nil {\n\t\t//nolint:forbidigo // used in test code only\n\t\tpanic(fmt.Sprintf(\"error getting env %v\", cassandraPortEnv))\n\t}\n\treturn p\n}\n\nfunc GetESAddress() string {\n\taddr := os.Getenv(esSeedsEnv)\n\tif addr == \"\" {\n\t\taddr = GetLocalhostIP()\n\t}\n\treturn addr\n}\n\nfunc GetESPort() int {\n\tport := os.Getenv(esPortEnv)\n\tif port == \"\" {\n\t\treturn esDefaultPortEnv\n\t}\n\tp, err := strconv.Atoi(port)","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/temporal/environment/env.go#L69-L105","documentation":"GetCassandraPort reads CASSANDRA_PORT from the environment for test clusters. If the variable is set but not a valid integer, strconv.Atoi fails and the helper panics. The panic is intentional (test-only code) because a non-numeric port means the test environment is misconfigured.","triggerScenarios":"Calling GetCassandraPort (temporal/environment/env.go:87) — directly or via NewTestCluster/NewCassandraConfig/test CQL clients — with CASSANDRA_PORT set to a non-integer value like \"9042tcp\", \"\", whitespace, or a host:port string.","commonSituations":"CI config where the port env var includes quotes or extra characters; docker-compose port mappings like \"9042:9042\" pasted into the env var; typos in .env files.","solutions":["Fix the CASSANDRA_PORT env var to a plain integer (e.g. 9042)","Unset CASSANDRA_PORT to fall back to the default cassandra port","Sanitize the value (trim spaces, strip anything after ':') before running tests"],"exampleFix":"// before\nexport CASSANDRA_PORT=\"9042:9042\"\n// after\nexport CASSANDRA_PORT=9042","handlingStrategy":"validation","validationCode":"port := os.Getenv(\"CASSANDRA_PORT\")\nif port != \"\" {\n    if _, err := strconv.Atoi(port); err != nil {\n        panic(\"CASSANDRA_PORT must be an integer, got: \" + port)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate all *_PORT env vars are numeric in CI before running tests","Avoid exporting docker publish syntax or DSNs into plain port variables","Quote-check .env files and strip whitespace/CRLF","Leave port vars unset to use defaults when unsure"],"tags":["panic","env-var","test-infrastructure","cassandra"],"backgroundTag":"invalid-env-var-format","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}