{"record":{"id":"15b8cb75562ae4b9","repo":"vitessio/vitess","slug":"error-creating-vtsql-connection-config-w","errorCode":null,"errorMessage":"error creating vtsql connection config: %w","messagePattern":"error creating vtsql connection config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"go/vt/vtadmin/cluster/cluster.go","lineNumber":122,"sourceCode":"\t\tcfg:  cfg,\n\t}\n\n\tdiscoargs := buildPFlagSlice(cfg.DiscoveryFlagsByImpl[cfg.DiscoveryImpl])\n\n\tdisco, err := discovery.New(cfg.DiscoveryImpl, cluster.ToProto(), discoargs)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error creating discovery impl (%s): %w\", cfg.DiscoveryImpl, err)\n\t}\n\n\tcluster.Discovery = disco\n\n\tprotocluster := cluster.ToProto()\n\n\tvtsqlargs := buildPFlagSlice(cfg.VtSQLFlags)\n\n\tvtsqlCfg, err := vtsql.Parse(protocluster, disco, vtsqlargs)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error creating vtsql connection config: %w\", err)\n\t}\n\n\tfor _, opt := range cfg.vtsqlConfigOpts {\n\t\tvtsqlCfg = opt(vtsqlCfg)\n\t}\n\n\tvtctldargs := buildPFlagSlice(cfg.VtctldFlags)\n\n\tvtctldCfg, err := vtctldclient.Parse(protocluster, disco, vtctldargs)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error creating vtctldclient proxy config: %w\", err)\n\t}\n\n\tfor _, opt := range cfg.vtctldConfigOpts {\n\t\tvtctldCfg = opt(vtctldCfg)\n\t}\n\n\tcluster.DB, err = vtsql.New(ctx, vtsqlCfg)","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtadmin/cluster/cluster.go#L104-L140","documentation":"cluster.New fails when vtsql.Parse cannot build the vtgate SQL connection config from the cluster's proto representation and the provided vtsql flags. The wrap keeps the parse error (unknown flag, bad value) as the cause. It occurs at vtadmin startup, before any connection is actually made.","triggerScenarios":"cfg.VtSQLFlags contains an unknown/invalid flag (e.g. wrong vtgate target or credentials flag) that vtsql.Parse rejects.","commonSituations":"Misconfigured vtgate host/port or keyspaces/shards target string; flag name that does not exist on this vitess version; passing pflags with malformed values.","solutions":["Fix the vtsql flags in the vtadmin cluster config (vtgate addresses, target, credentials)","Run vtadmin with only the documented vtsql flags and add back one at a time","Verify flag names against the vtsql package for your vitess version"],"exampleFix":"// before\nvt: \"-vtgate-host badhost -vtgate-port notaport\"\n// after\nvt: \"-vtgate-host vtgate.example.com -vtgate-port 15999\"","handlingStrategy":"validation","validationCode":"// pre-validate vtsql flags before BuildCluster\nif err := validateFlagNames(\"vtsql\", cfg.VtSQLFlags); err != nil {\n    return fmt.Errorf(\"bad vtsql flags: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"c, err := cluster.BuildCluster(ctx, cfg)\nif err != nil {\n    if strings.Contains(err.Error(), \"vtsql connection config\") {\n        return fmt.Errorf(\"check --vt flags for cluster %q: %w\", cfg.ID, err)\n    }\n    return err\n}","preventionTips":["Pin vtadmin and vitess versions so flag names match","Run a config smoke test in CI that constructs every cluster","Avoid hand-written flag strings; generate them from templates with known-good values"],"tags":["startup","vtsql","configuration","flag-parsing"],"backgroundTag":"invalid-config-flag","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}