{"record":{"id":"7507f43a134ba9c6","repo":"gastownhall/beads","slug":"register-tls-config-w","errorCode":null,"errorMessage":"register TLS config: %w","messagePattern":"register TLS config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/uow/external_doltserver_provider.go","lineNumber":83,"sourceCode":"\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"uow: get proxy endpoint: %w\", err)\n\t}\n\n\treturn openAndInitSchema(ctx, ep, database, rootUser, rootPassword, tlsConfigName, teamServer, expectedProjectID, applyProviderOptions(opts))\n}\n\nfunc registerExternalTLSConfig(external configfile.ExternalDoltConfig) (string, error) {\n\tif !external.TLSRequired {\n\t\treturn \"\", nil\n\t}\n\ttc, err := external.TLSClientConfig()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tname := \"beads-external-\" + server.ExternalDoltServerID(external)\n\tif err := mysql.RegisterTLSConfig(name, tc); err != nil {\n\t\treturn \"\", fmt.Errorf(\"register TLS config: %w\", err)\n\t}\n\treturn name, nil\n}\n","sourceCodeStart":65,"sourceCodeEnd":87,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/uow/external_doltserver_provider.go#L65-L87","documentation":"registerExternalTLSConfig fails with this when the go-sql-driver mysql package rejects the TLS config registration via mysql.RegisterTLSConfig. In practice this happens when the config name \"beads-external-<serverID>\" is already registered with a different *tls.Config, or the supplied config is invalid per the driver's rules (nil key data etc.). The name is derived from the external server ID, so the same server config re-registered with changed TLS material collides.","triggerScenarios":"Calling NewExternalDoltServerUOWProvider twice in one process with TLSRequired=true for the same external server but a changed tls.Config (e.g. different CA/cert after rotation, or tests constructing providers repeatedly), so mysql.RegisterTLSConfig(\"beads-external-<id>\", tc) returns an error.","commonSituations":"Test suites or long-lived daemons that recreate providers per operation; TLS cert rotation changing the config while the driver retains the old registration; two ExternalDoltConfigs hashing to the same server ID.","solutions":["Reuse one provider instance per server instead of reconstructing it repeatedly in the same process.","Call mysql.DeregisterTLSConfig(\"beads-external-<serverID>\") before re-registering when the TLS material legitimately changed.","If the material didn't change, treat registration as idempotent in your wrapper and ignore/reuse the existing config name.","Check whether two different configs accidentally produce the same server ID (same host/port/socket fields)."],"exampleFix":"// before\nname := \"beads-external-\" + server.ExternalDoltServerID(external)\nif err := mysql.RegisterTLSConfig(name, tc); err != nil {\n\treturn \"\", fmt.Errorf(\"register TLS config: %w\", err)\n}\n// after\nname := \"beads-external-\" + server.ExternalDoltServerID(external)\nif _, exists := mysql.TLSConfigMap[name]; !exists {\n\tif err := mysql.RegisterTLSConfig(name, tc); err != nil {\n\t\treturn \"\", fmt.Errorf(\"register TLS config: %w\", err)\n\t}\n}","handlingStrategy":"try-catch","validationCode":"// check for an existing registration before re-creating the provider\nif _, exists := mysql.TLSConfigMap[\"beads-external-\"+server.ExternalDoltServerID(external)]; exists {\n\tmysql.DeregisterTLSConfig(\"beads-external-\" + server.ExternalDoltServerID(external))\n}","typeGuard":null,"tryCatchPattern":"if err := registerProvider(); err != nil {\n\tif strings.Contains(err.Error(), \"register TLS config:\") {\n\t\t// same-name collision: deregister and retry once\n\t\tmysql.DeregisterTLSConfig(\"beads-external-\" + server.ExternalDoltServerID(external))\n\t\treturn registerProvider()\n\t}\n\treturn err\n}","preventionTips":["Create the provider once per process and share it, not per-operation.","Deregister TLS configs when tearing down providers in tests.","Keep TLS material stable for a given server ID; bump the ID when rotating.","Avoid two ExternalDoltConfigs that share host/port/socket but differ in TLS settings."],"tags":["tls","mysql-driver","registration-conflict"],"backgroundTag":"tls-config-registration-conflict","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}