{"record":{"id":"2ba202581fc82b1e","repo":"apache/beam","slug":"batch-failed-to-marshal-worker-uuid-v","errorCode":null,"errorMessage":"batch: failed to marshal worker UUID: %v","messagePattern":"batch: failed to marshal worker UUID: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/transforms/batch/batch.go","lineNumber":509,"sourceCode":") {\n\temit(ShardedKey[K]{Key: key, ShardID: makeShardID()}, value)\n}\n\nvar (\n\tworkerUUIDOnce sync.Once\n\tworkerUUIDVal  [16]byte\n\tshardCounter   atomic.Uint64\n)\n\n// makeShardID returns a 24-byte shard identifier: a 16-byte worker\n// UUID fixed per process plus an 8-byte atomic counter, big-endian.\n// The layout mirrors the Java and Python shapes exactly so the wire\n// bytes of cross-language round-trips remain aligned.\nfunc makeShardID() []byte {\n\tworkerUUIDOnce.Do(func() {\n\t\tb, err := uuid.New().MarshalBinary()\n\t\tif err != nil {\n\t\t\tpanic(fmt.Sprintf(\"batch: failed to marshal worker UUID: %v\", err))\n\t\t}\n\t\tcopy(workerUUIDVal[:], b)\n\t})\n\tout := make([]byte, 24)\n\tcopy(out[:16], workerUUIDVal[:])\n\tcounter := shardCounter.Add(1)\n\tbinary.BigEndian.PutUint64(out[16:24], counter)\n\treturn out\n}\n\n// writeVarInt writes a varint-encoded int64 to buf (unsigned,\n// little-endian base-128).\nfunc writeVarInt(buf *bytes.Buffer, v int64) {\n\tu := uint64(v)\n\tfor u >= 0x80 {\n\t\tbuf.WriteByte(byte(u) | 0x80)\n\t\tu >>= 7\n\t}","sourceCodeStart":491,"sourceCodeEnd":527,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/transforms/batch/batch.go#L491-L527","documentation":"makeShardID lazily generates a per-worker UUID via uuid.New().MarshalBinary() and panics if marshaling the UUID bytes fails. Google's UUID MarshalBinary virtually never fails (UUIDs are fixed 16 bytes), so this panic represents an unexpected internal invariant break while constructing the 24-byte shard ID.","triggerScenarios":"First call to makeShardID in the worker process (guarded by workerUUIDOnce) where uuid.New().MarshalBinary() returns a non-nil error; also reachable through shard-ID generation from batch element processing.","commonSituations":"See trigger scenarios.","solutions":["Inspect the error message; if uuid.New() returned an invalid UUID, check for tampered/incorrect use of the uuid package.","Ensure the google/uuid dependency is intact and at a normal version (go mod tidy / go mod download).","Regenerate go.sum/vendor if the module cache is corrupted.","As a last resort, replace with a known-good UUID construction (uuid.Must(uuid.NewRandom())) in a fork."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"defer func() {\n\tif r := recover(); r != nil {\n\t\tlog.Fatalf(\"shard ID init failed: %v\", r) // init-time failure is fatal\n\t}\n}()","preventionTips":["Keep the google/uuid module dependency healthy (go mod verify)","Avoid vendoring with a corrupted module cache","Treat UUID marshal failures as a fatal environment problem"],"tags":["go","apache-beam","uuid","panic"],"backgroundTag":"internal-invariant-violation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}